1.3 Basic Commands


1.3 Basic Commands

It's time to learn some other Unix commands. Most of the following programs take multiple arguments, and some have so many options and formats that an unabridged listing would be pointless. This is a simplified list; you don't need to know all of the details just yet.

1.3.1 ls

The ls command lists the contents of a directory. The default is the current directory. Use ls -l for a detailed (long) listing and ls -F to display file type information (for more on file types and the permissions in the left column, see Section 1.17). Here is a sample long listing:

 total 3616 -rw-r--r-- 1  juser    users       3804 Apr 30  2000 abusive.c -rw-r--r-- 1  juser    users       4165 May 26  1999 battery.zip -rw-r--r-- 1  juser    users     131219 Oct 26  2000 beav_1.40-13.tar.gz -rw-r--r-- 1  juser    users       6255 May 30  1999 country.c drwxr-xr-x 2  juser    users       4096 Jul 17 20:00 cs335 -rwxr-xr-x 1  juser    users       7108 Feb  2  2001 dhry -rw-r--r-- 1  juser    users      11309 Oct 20  1999 dhry.c -rw-r--r-- 1  juser    users         56 Oct  6  1999 doit drwxr-xr-x 6  juser    users       4096 Feb 20 13:51 dw drwxr-xr-x 3  juser    users       4096 May  2  2000 hough-stuff 

1.3.2 cp

In the first form shown below, cp copies the contents of file1 to file2 . In the second form, it copies all files to the dir directory:

 cp  file1 file2  cp  file1  ...  fileN dir  

1.3.3 mv

In the first form below, mv renames file1 to file2 . In the second form, it moves all files to the dir directory:

 mv  file1 file2  mv  file1  ...  fileN dir  

1.3.4 touch

The touch command creates a file. If the file already exists, touch does not change it, but it does update the timestamp you see with the long listing that you get with the ls -l command.

 touch  file  

1.3.5 rm

To delete (remove) a file, use rm . After you remove a file, it's gone. Do not expect to be able to "undelete" anything.

 rm  file  

1.3.6 echo

The echo command prints its arguments to the standard output:

 echo Hello there. 

The echo command is very useful for finding expansions of shell wildcards and variables that you will encounter later in this chapter.




How Linux Works
How Linux Works: What Every Superuser Should Know
ISBN: 1593270356
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Brian Ward

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net