Presentation is loading. Please wait.

Presentation is loading. Please wait.

©Colin Jamison 2004 Introduction to Linux Colin Jamison.

Similar presentations


Presentation on theme: "©Colin Jamison 2004 Introduction to Linux Colin Jamison."— Presentation transcript:

1 ©Colin Jamison 2004 Introduction to Linux Colin Jamison

2 ©Colin Jamison 2004 Help on Unix Commands List all options available for a command and also some example usage e.g. man command-name As for ‘man’ but the ‘info’ command has more information and is up to date e.g. info command-name

3 ©Colin Jamison 2004 UNIX Command Format command The first word is the command Options follow commands Commands/options/arguments are case sensitive A command may or may not have options $ ls $ ls -al Arguments are normally files/directories $ ls -al /etc

4 ©Colin Jamison 2004 Directory and File Names Case sensitive Any character Avoid “ / * > space ! ” –they are legal but their use is problematic with shells Must be unique inside its directory Wildcard – *any number of characters – ?any single character – [ ]Any one of the characters inserted between the brackets

5 ©Colin Jamison 2004 Path Names Path name - is an address that uniquely identifies a file or directory in the UNIX file system. Absolute path name - always starts from the root directory e.g. /usr/local/bin Relative path name - path relative to the present working directory e.g. if pwd is /usr relative pathname local/bin is equivalent to the absolute pathname /usr/local/bin

6 ©Colin Jamison 2004 Directory Navigation Changing directory $ cd /usr $ cd local/bin $ cd.. Present directory $ pwd /home/cjamison/ Creating/removing directories $ mkdir directoryname $ rmdir directoryname

7 ©Colin Jamison 2004 Directory Contents File listing $ ls - abbreviated list $ ls -a - abbreviated list + hidden files $ ls -al - long list + hidden files $ ls -F - abbreviated list + file type

8 ©Colin Jamison 2004 bash2.04$ ls -l total drwxr-xr-x 1 cjamison staff 123 Dec 12 2003 Aproject -rwx--x--x 1 cjamison staff 514 Dec 24 2003 Ascript -rwxr--r-- 1 cjamison staff 2345 Jan 02 2004 afile -rwxr--r-- 1 cjamison staff 231 Aug 12 2003 checksum -rwxr-x--x 1 cjamison staff 126 Dec 24 1990 dos2unix -rwx------ 1 cjamison staff 732 Oct 23 2003 dev.txt -rwxr-x--x 1 cjamison staff 9470 Aug 26 2003 excalibur drwxr-x--x 1 cjamison staff 512 Dec 10 2003 home drwx------ 1 cjamison staff 512 Jan 16 2004 mp3 drwx------ 1 cjamison staff 512 Sep 01 2003 payroll -rwxr-x--- 1 cjamison staff 8972 Aug 21 2003 swallow -rw------- 1 cjamison staff 42 Dec 24 2003 swift.txt bash2.04$ File listing type access permission owner group size date and time last modified name

9 ©Colin Jamison 2004 Access Permissions Access permissions on a directory determine whether a file in the directory can be renamed or removed File permissions determine what can be done to the file contents To allow access to a directory, access permissions should be set for all of its parent directories all the way up to the root directory

10 ©Colin Jamison 2004 Access Permissions The first character indicates the type of file: –directory (d) –link (l) –plain file (-) -rwxrwxr-x l The rest, specify three types of users m owner m group m others l who are allowed to m (r) read m (w) write m (x) execute

11 ©Colin Jamison 2004 Numerical Access Permissions -|rwx|r-x|r--| |111 |101|100| Character Binary Octal | 7 | 5 | 4 |

12 ©Colin Jamison 2004 Protecting Your Files -r-- --- --- (400) protect it from accidental editing -rw- --- --- (600) owner can edit/read the file -rw- r-- r-- (644) owner can edit, others may read -rw- rw- rw- (666) everyone can edit/read dr-x r-x r-x (555) everyone can list but can’t create delete/rename files drwx --- --- (700) owner can do anything drwx r-x r-x (755) owner can do anything, others can read drwx rwx rwx (777) anyone can edit/read/run

13 ©Colin Jamison 2004 Changing Access Permissions chmod permission files Character Method $ chmod a=r-x filename $ chmod u=rwx filename $ chmod go+r filename $ chmod ugo-w filename Numerical Method $ chmod 755 filename $ chmod 600 filename

14 ©Colin Jamison 2004 Viewing and Editing Files Listing files –cate.g. cat filename –taile.g. tail -f filename Listing files one screen at a time –moree.g. cat filename | more Editing files –vi –emacs –GUI tools

15 ©Colin Jamison 2004 File Manipulation Copy –cp filename1 filename2 move (rename) –mv filename directory remove (delete) - be careful! –rm filename

16 ©Colin Jamison 2004 Listing Processes List processes e.g. ps ps -ef

17 ©Colin Jamison 2004 Processes - Foreground v Background To run a process as a background process: process-name & To examine foreground/background processes use the jobs command fg bg Each process has a unique process id (PID)

18 ©Colin Jamison 2004 Disposing of Rogue Processes The kill command kill parameter PID parameters ‘-1’ to ‘-9’ PID available from one of the process commands

19 ©Colin Jamison 2004 Redirection (1) ls -al > lsoutput1.txt ls -al >> lsoutput2.txt file descriptors standard input 0 standard output 1 standard error 2

20 ©Colin Jamison 2004 Redirection (2) Redirect standard error to a file ls -al > lsout.txt 2>lserror.txt redirect standard output and standard error to the same file ls -al > lsout.txt 2>&1 Redirecting input more < lsout.txt To discard standard output and standard error ls -al > /dev/null 2>&1

21 ©Colin Jamison 2004 Pipes Simplify redirection e.g. ps | sort | more ps | grep ‘sh’ > listshells.txt

22 ©Colin Jamison 2004 ‘C’ Tools (gcc) gcc - GNU C/C++ compiler gcc filename1 … filenameX -o programfilename most commonly used options [-Idir...] search dir for header files [-Ldir…] include dir to search for library ( -llibrary ) [-o outfile] [-ggdb] include gdb debugging information

23 ©Colin Jamison 2004 ‘C’ Tools (gdb) gdb - GNU debugger gdb programfilename most commonly used options run break [file:]functionprint expr next step c edit [file:]function list help command quit

24 ©Colin Jamison 2004 Questions ?


Download ppt "©Colin Jamison 2004 Introduction to Linux Colin Jamison."

Similar presentations


Ads by Google