UNIX File Systems - Working with Directories and Files
(Page 4 of 5 )
For creating directories, we use the mkdir and the rmdir commands. This is going to be followed by the argument for the new file name or the directory we want to delete.
#create a directory in the current working directory
mkdir alfa
#removes directory alfa what has no items inside.
rmdir alfa
You can move the working directory with the cd command.
#move up a level
cd ..
#move into directory alfa what you will find in the working
#directory
cd alfa
#move into the alfa directory found a level up to the home dir
cd ~/../alfa
We can create files with the touch command. This will either just update the last modification status if the file is already created, or create it if it does not exist. The files inside UNIX are just a stream of bytes. They can be binary files and text file. You can also read the text files.
#create a file into the current working directory
touch omega
Further tasks include copy (cp), remove (rv), move or rename files/directories(mv).
#copy [what] [where] => copy alfa file into beta directory
cp alfa ~/beta
#rm [what file] =>Remove alfa file from the working directory
rm alfa
These commands will not return any message if everything goes correctly. We can get information about a file with the already-presented ls command; to review this command, see my article about the terminal and the commands file and stat. Just enter the name of a file as an argument with its route, and you will see what information this offers.
The text files are the most used, as most of the programs communicate in this manner with the user. The end of line character is only the 10 ASCI code character (n). This is as opposed to Windows, where this is followed by a carriage return (r).
Files can be of zero length (empty files) and up to 2 GB on 32-bit operating systems, and up to eight billion GB on the 64-bit ones. To just give an idea of the size of eight billion GB let me tell you that a hard drive with current technology writing a file of this size would take several thousand years.
Next: Devices >>
More Miscellaneous Articles
More By Gabor Bernat