$mkdir letters $ls -F4
We create a new directory using the mkdir command (make directory).
$mv dict letters $ls letters/dict
Now we move the dict into the directory letters using the mv command ( move).
$mv dict* letters Here the character * matches any sequence of characters, including the null string. Thus files starting with dict would all be moved into letters.
$cd letters $ls dict Sometimes it is better to work inside the directory letters. To do it we use the cd command (chhange directory).
$cd To go back to our home directory.
$ls -al We check what our home directory contains.
$mkdir cprogs; mv *.c cprogs $ls -F cprogs/ letters Now we make directory for the other files and move them into the right places.
$pwd
ozdogan
$cd letters $pwd
ozdogan/letters
$rm * $cd .. $rmdir letters
To remove a directory we first remove all the file in it, then remove the directory with rmdir (remove directory).
The command rm * removes all files in the current directory.
The command cd .. changes the current directory to the parent of the current one. In this case, it changes us from ozdogan/letters to ozdogan .
To investigate other flags to the command you are interested in type:
$man commandname
For example, to investigate other flags to the ls command (such as which flags will display file size and ownership) you would type man ls.
Now type $ls -as lists all files, and lists their sizes in kilobytes.
The command ls -lfilename will list the long directory list entry (which includes owner and permission bits) and the group of a file.
The output looks something like:
permission owner group filename
-rw-r----- 1 ozdogan ozdogan 65538 Feb 6 01:44 commands.html
The Permission Bits;
The first position (which is not set) specifies what type of file this is. If it were set, it would probably be a d (for directory) or l (for link).
The next nine positions are divided into three sets of binary numbers and determine permissions for three different sets of people.
u g o
421 421 421
rw- r-- ---
6 4 0
The file has "mode" 640.
The first bits, set to "r + w" (4+2=6) in our example, specify the permissions for the user who owns the files (u).
The user who owns the file can read or write (which includes delete) the file.
The next trio of bits, set to "r" (4) in our example, specify access to the file for other users in the same group (g) as the group of the file.
In this case the group is ug - all members of the ug group can read the file (print it out, copy it, or display it using more).
Finally, all other users (o) are given no access to the file.
The one form of access which no one is given, even the owner, is "x" (for execute).
This is because the file is not a program to be executed.
It is probably a text file which would have no meaning to the computer. The x would appear in the third position if it was an executable file.
If you wanted to make the file readable to all other users, you could type:
$chmod 644 filename or chmod o+r filename
To avoid unwanted deletion of precious files the mv and rm commands can be made interactive using the -i flag. For example rm -i filename would return a prompt asking if you are certain you want to delete that file.
$du Display disk usage of the current directory and its subdirectories.
$du -s Display only total disk usage.
$du -s -k Some versions of UNIX, such as Solaris, need -k to report kilobytes.
$df To examine what disks and partitions exist and are mounted, you can type the df command at the $ prompt. It will display the space used and available in kilobytes and the "mount point" or directory of the partition.
$ps uax The ps command used to list your own processes can be used to list other users' processes as well.
$top top is an interactive command that displays and periodically updates the top cpu processes, ranked by raw cpu percentage.
The default number of processes displayed is 15 but you can specify the number of processes with top number (e.g. to specify the top 10 processes enter top 10).