This article applies to 123 Reg Linux VPS hosting
What is Unix?
UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops.Listing files and directories
ls (list) The ls command (lowercase L and lowercase S) lists the contents of your current working directory. There may be no files visible in your home directory, in which case, the UNIX prompt will be returned. Alternatively, there may already be some files inserted by the System Administrator when your account was created. ls does not, in fact, cause all the files in your home directory to be listed, but only those ones whose name does not begin with a dot (.) Files beginning with a dot (.) are known as hidden files and usually contain important program configuration information. ls -a lists files that are normally hidden.Making Directories
mkdir (make directory) We will now make a subdirectory in your home directory. To make a subdirectory called unixstuff in your current working directory type
# mkdir unixstuff
# ls
Changing to a different directory
cd (change directory) The command cd directory means change the current working directory to ‘directory’. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree. To change to the directory you have just made, type
# cd unixstuff
# cd .
# cd ..
Please note: Typing cd with no argument always returns you to your home directory. This is very useful if you are lost in the file system.
Pathnames
pwd (print working directory) Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, type cd to get back to your home-directory and then type
# pwd
Copying Files
cp (copy) The command cp will make a copy of a file in the current working directory, to make a copy of file1 and call it file2 type
# cp file1 file2
Moving Files
mv (move) To move a file from one place to another, use the mv command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two. It can also be used to rename a file, by moving the file to the same directory, but giving it a different name. To move (or renames) file1 to file2 type
# mv file1 file2
Removing files and directories
rm (remove), rmdir (remove directory) To delete (remove) a file, use the rm command. To delete file1 type
# rm file1
Displaying the content of a file on the screen
clear (clear screen) If your screen is cluttered you may like to to use the clear command clear the terminal window of the previous commands so the output of the following commands can be clearly understood. At the prompt, type
# clear
# cat filename.txt
# less filename.txt
# head -15 filename.txt
# grep word filename.txt
# df .
Summary
Command | Meaning |
---|---|
ls | List files and directories |
ls -a | List all files and directories |
mkdir | Make a directory |
cd directory | Change to named directory |
cd | Change to root directory |
cd .. | Change to parent directory |
pwd | Display the path of the current directory. |
cp file1 file2 | Copy file1 and call it file2 |
mv file1 file2 | Move or rename file1 to file2 |
rm file | Remove a file |
rmdir directory | Remove directory |
cat file | Display a file |
less file | Display a file a page at a time |
head file | Display the first few lines of a file |
tail file | Display the last few lines of a tile |
grep ‘keyword’ file | Search a file for keywords |
df | Quota and Diskspace |