16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Unix</strong><br />

<strong>Working</strong> <strong>with</strong> Files<br />

! Print <strong>Working</strong> directory<br />

When you log in you are placed in your home directory.<br />

$ pwd<br />

! Listing Directory Contents<br />

$ ls short list<br />

$ ll long list<br />

-rw-rw-r-- 1 user group 1000 Feb 1 12:00 filename<br />

permissions number owner group size in time of modification filename<br />

of links<br />

bytes<br />

! Changing your directory<br />

$ cd /usr/local/bin verify <strong>with</strong> command "pwd"<br />

$ cd .. move up one directory<br />

$ cd / change to "root" directory<br />

$ cd return home<br />

! Making and Removing directories<br />

$ mkdir books<br />

$ rmdir texts<br />

! Renaming or moving files<br />

$ mv books texts moves books to texts<br />

! Copying files<br />

$ cp filel file2 copies file1 to file2<br />

! Displaying files<br />

$ cat filename display file on screen<br />

$ more filename waits every screen to continue<br />

$ tail filename displays last 10 lines<br />

$ tail -20 file displays last 20 lines<br />

$ head -30 file display first 30 lines<br />

! Deleting Files<br />

$ rm filename<br />

$ rm -i file confirm before deleting<br />

! Finding Files (mary)<br />

find pathname -name filename -print<br />

e.g. $ find / -name ls -print<br />

! Searching Files<br />

grep keyword filenames<br />

e.g. $ grep user_name /etc/passwd<br />

! Word Count<br />

$ wc /etc/motd count of lines, words, character<br />

$ who | wc -l returns number of users<br />

! Printing files<br />

$ lp filename<br />

lp-201 request ID Note: directory must be "publicly executable"<br />

14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!