Contents
|
1.
|
|
|
2.
|
|
|
3.
|
|
|
4.
|
|
|
5.
|
|
1. "man"
|
|
Display Manual Pages
|
The man command will display the manual pages for most UNIX
commands. For more information on any of the Unix commands below, use this to
see if there is an online manual page available. For example, if you require
help on the move (mv) command, you would type:
man mv
The command syntax for man is:
man commandname
By default, the man command uses another command called more to
display the manual page one screenfull at a time. To display the next screen,
press the space bar. To end the display before the end of the file, press the
"q" key.
|
2. "ls"
|
|
List the contents of a directory
|
Use this command to list the contents of the current directory.
This will display all files and directories within the current directory in a
columnar format.
You may change the format in which ls displays your directory
listing by adding options to the ls command. To add an option to the command,
follow the ls command with a minus sign '-' and the option(s) you wish to add.
For example, ls -l will list the current directory in long format, showing
size, date, and permissions. ll is a common alias or shortcut for the list long
command (ls -l).
In Unix, there are files which are normally hidden called
"dotfiles". These dotfiles are files that start with a dot (i.e. a
period - ".") and are used by programs and shells to retain control
information such as preference settings and bookmarks. To see hidden files, use
ls -a to list all files, including those files whose names begin with a period.
Be careful not to remove dotfiles if you're not sure of their purpose.
The command syntax for ls is :
ls [
-aAcCdfFgilLqrstux ] filename
If you use the ls command on a directory with many files, the
display will probably scroll off the screen. To avoid this, you can
"pipe" the display through the more command, just as with man pages.
The Unix "pipe" symbol is a vertical bar (often a broken vertical bar
on your keyboard). It means "take the command on the left, and use it as
input to the command on the right". For example:
ls -la | more
Which lists the content of the current directory, in long format
(-l) and includes all files (-a), and sends the listing to the more command
which displays the listing one screen at a time.
|
3. "cd" - and
"mkdir" |
|
Change Directory
Make Directory |
The "change directory" command is used to switch from
one directory to another. The purpose of having multiple directories is to
enable you to easily organize your files. Your directory structure should
resemble a filing cabinet, with folders (directories) for each set of files.
Using cd without a directory name following it will always
return you to your home directory, no matter where you are in the Unix
directories. To change to a subdirectory, for example one called
"skiing", you would type:
cd skiing
To "back up" a level in the directory structure from a
subdirectory to its parent directory, you can use:
cd ..
.. is a special directory which always links a directory
backwards to its parent directory, you can see this directory with the ls -a
command. There is a second special directory called . which always refers to
the current directory.
The command syntax for cd is :
cd
[directoryname]
The "make directory" command is used to create a new
directory. As noted above, a directory serves to organize files in a manner to
similar to a filing cabinet. However, unlike most filing cabinets, a single
directory may contain several subdirectories. For example, to create a
directory called "Banff":
mkdir Banff
The command syntax for mkdir is:
mkdir
directoryname
|
|
Remove files
Remove Directories |
The "remove" command is used to permanently delete
your files from your directories. To remove a file named "whistler.ps"
from the current directory:
rm whistler.ps
To remove multiple files, use the remove command followed by the
names of the files, separated by spaces. For example:
rm file1 file2
file3
The command syntax for rm is:
rm [-fir]
filename
The "remove directory" command is used to delete your
directories. The directory you wish to remove must be empty before using the
rmdir command. To remove a directory called "bigsky", you would type:
rmdir bigsky
The command syntax for rmdir is:
rmdir directoryname
To remove a directory that is not empty (and all of its
contents) you can use the rm command with the -r (recursive) option. This will
recursively remove all files from a directory (or subdirectories) and then
remove the directory itself. Repeating the previous example:
rm -r bigsky
|
|
Copy files
|
The "copy" command is used to make a copy of a file in
the same or a different directory. If copying to the same directory the
filename of the copy must be different. This is useful for making backups or
working copies of files while leaving the originals alone. To copy the file
tahoe.txt to a backup file tahoe.txt.bak in the same directory:
cp tahoe.txt
tahoe.txt.bak
To copy the file named "tahoe.txt" from your home
directory to a directory named "goodskiing" (without changing the
name):
cp tahoe.txt
goodskiing
If you wished to rename the copied file:
cp tahoe.txt
goodskiing/newname.txt
The command syntax for cp is:
cp [ -ip ] filename1 filename2
Good article for beginners! Thanks for sharing
ReplyDeletegood
ReplyDelete