Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.

Similar presentations


Presentation on theme: "1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full."— Presentation transcript:

1 1 Linux Commands

2 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full path name starts with the root, /, and follows the branches of the file system, each separated by /, until you reach the desired file. A relative path name specifies the path relative to another, usually the current working directory that you are at. Two special directory entries should be introduced now: . the current directory .. the parent of the current directory % cd /home/hls/notes % cd./notes

3 3 Working with Folders (Directory) 1- ls ( list directory content) ls This command outputs a list of the files in the current directory ls ~ This command outputs a list of the files that are in your home directory 2- mkdir (make directory) mkdir dir1 mkdir dir1/dir2

4 Exploring Command Shell 3- cd ( c hange d irectory) – cd / This command navigate you to the root directory – cd dir1 This command moves you to dir1 – cd dir1/dir2 This command moves you to dir2 – cd ~ This command navigate you to your home directory (it is equivalent to cd /home/username/ ) – cd.. To navigate up one directory level – cd - To navigate to the previous directory (or back) 4

5 Exploring Command Shell 4- rmdir (remove directory) – rmdir dir1/dir2 Removes the directory that is named dir2 in side the sub directory dir1) – rmdir dir1 To Remove any directory it should be empty This command removes the empty directory named dir1 5- pwd (print working directory) – pwd display which directory your are currently located in 5

6 6 Working with Files 6- touch (create file) – touch file1 7- rm ( r e m ove file) – rm file1

7 7 Directory Navigation Navigation and directory control command     pwd (print working directory): At any time you can determine where you are in the file system hierarchy with the pwd, print working directory, command, e.g.: % pwd /home/user/Desktop/cs002 % pwd /home/user/Desktop/cs002

8 8 File Maintenance Commands cp (copy a file): copy the contents of one file to another. mv (move a file): Rename a file. % cp old_file new_file % mv old_name new_name

9 9 Display the Content of a File cat (concatenate a file): display the content of a file.  Common Options: -n precede each line with a line number. what about this command: $ cat filename This is the content of filename. It contains two line. $ cat filename This is the content of filename. It contains two line. $ cat -n filename 1 This is the content of filename. 2 It contains two line. $ cat -n filename 1 This is the content of filename. 2 It contains two line. $ cat file1 file2 file3

10 10 head: displays the head, or start, of the file. 40 = head line no tail : displays the tail, or end, of the file. % head -40 filename. % tail -30 filename Display the Content of a File

11 11 Uniq (remove duplicate lines):  The uniq utility displays a file, skipping adjacent duplicate lines, but does not change the original file.  If a file contains a list of names and has two successive entries for the same person, uniq skips the extra line. %cat file 1 2 3 6 4 5 3 6 7 8 9 0 %uniq file 1 2 3 6 4 5 3 6 7 8 9 0 %cat file 1 2 3 6 4 5 3 6 7 8 9 0 %uniq file 1 2 3 6 4 5 3 6 7 8 9 0 Display the Content of a File

12 12 wc (count words in a file): stands for "word count"; the command can be used to count the number of lines, characters, or words in a file.  Common Options: -c count characters -l count lines -w count words  If no options are specified it defaults to "-lwc". %cat users jdoe John Doe 4/15/96 lsmith Laura Smith 3/12/96 pchen Paul Chen 1/5/96 jhsu Jake Hsu 4/17/96 sphilip Sue Phillip 4/2/96 % wc users 5 20 121 users %cat users jdoe John Doe 4/15/96 lsmith Laura Smith 3/12/96 pchen Paul Chen 1/5/96 jhsu Jake Hsu 4/17/96 sphilip Sue Phillip 4/2/96 % wc users 5 20 121 users Display the Content of a File

13 13 sort ( sort file contents): The sort command is used to order the lines of a file. Common Options  -r reverse the sort  -u unique; omit multiple copies of the same line (after the sort) %cat users jdoe John Doe 4/15/96 lsmith Laura Smith 3/12/96 pchen Paul Chen 1/5/96 jhsu Jake Hsu 4/17/96 sphilip Sue Phillip 4/2/96 % sort -r users sphilip Sue Phillip 4/2/96 pchen Paul Chen 1/5/96 lsmith Laura Smith 3/12/96 jhsu Jake Hsu 4/17/96 jdoe John Doe 4/15/96 %cat users jdoe John Doe 4/15/96 lsmith Laura Smith 3/12/96 pchen Paul Chen 1/5/96 jhsu Jake Hsu 4/17/96 sphilip Sue Phillip 4/2/96 % sort -r users sphilip Sue Phillip 4/2/96 pchen Paul Chen 1/5/96 lsmith Laura Smith 3/12/96 jhsu Jake Hsu 4/17/96 jdoe John Doe 4/15/96 Manipulate the Content of the File

14 14 Displays the Time and Date date [options] [+format] Common Options  -u :use Universal Time (or Greenwich Mean Time)  +format: specify the output format %a weekday abbreviation, Sun to Sat %h month abbreviation, Jan to Dec %D MM/DD/YY date %T HH:MM:SS time %t $ date Thu Jan 20 10:24:00 PST 2008 $date -u Mon Jun 10 13:01:33 GMT 2008 $date +%a%t%D Mon 06/10/96 $ date Thu Jan 20 10:24:00 PST 2008 $date -u Mon Jun 10 13:01:33 GMT 2008 $date +%a%t%D Mon 06/10/96

15 Calculator ◮ bc: A text based calculator $ bc 2*10+20-9+4/2 [Input] 33 [Output] [ctrl+d] [Quit] ◮ xcalc is graphical based calculator

16 Clear - to clear the terminal window Free - Displays the amount of used and free system memory. Shutdown command examples Shutdown the system and turn the power off immediately. # shutdown -h now Shutdown the system after 10 minutes. # shutdown -h +10

17 System Admin In Linux uptime command shows since how long your system is running and the numbers of users are currently logged in. inutes intervals


Download ppt "1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full."

Similar presentations


Ads by Google