List of Basic Unix Commands

List of Basic Unix Commands

Developed first at the AT&T laboratories, Unix is now in the hands of different non profit organizations. This article provides you with a list of basic Unix commands.
Techspirited Staff
If you want to learn how an operating system works, learning Unix is perhaps the best way to do so. To get a proper understanding of this system, you need to have a list of basic Unix commands. This article will provide you with the same, and you will understand the purpose of each command. You will also understand why it is necessary to understand them thoroughly. They help us interact with the computer when using this operating system. This list is also similar to the one that is used for Linux, which is just like Unix.


An operating system is an interface between the user and the computer. The Unix operating system was designed to augment the same purpose. But, the approach was of an open source software. It is a system software and all the processes in the operating system can be controlled by the user. The core of this system is called the kernel. It is the kernel that is responsible for handling all the internal operations of the operating system. Right from the allocation of hardware, to multi-user and multitasking facilities, the tasks are carried out entirely by the kernel. This operating system provides you with facilities right from loading selected applications for a particular session, to terminating and resuming processes at will. There are commands to handle almost every operation.

List of Commands

File Handling


It is used for listing the files and directories in any directory. You just have to type ls at the prompt and you get all the files and folders in that particular directory. There are various switches too, that can help in listing the names of these files and directories. For example, if you type ls -a you can get the list of the hidden files along with the other files that have been listed. Hidden file names start with a (.) dot.


It is used for creating directories. For example, if you type mkdir abc, the directory abc will be created in the current directory.


This is used for changing from one directory to another. If you are working in the directory abc and you want to change to the directory cba, you need to type cd cba. In this case, the directory cba must be present within the directory abc. If the directory cba is not present within the directory abc, you cannot move over to that directory. Under such cases, you have to mention the entire path location to the directory cba starting from the root directory. Suppose the directory cba is present in the directory def under the root(/) directory, then you simply need to type, cd /def/cba, to move over to that directory. If you want to move over to the parent directory of abc, which is say buzzle, then you need to type cd .. .


If you have reached a directory through various other directories and you are not aware of the path to the directory, you can simply type in pwd and get the current location path. Suppose you are in the directory hij. hij was suppose created in the directory def, which is under the directory abc created under the root, then on typing pwd, what you get is; /abc/def/hij.

Copying, Moving, and Deleting


Suppose you want to create a copy of the file inventory.txt in your current directory. In such cases, the cp can be used to make the copy. cp /abc/inventory.txt inventorybackup.txt will copy the file inventory.txt in the directory abc created under the root to your current working directory and name it inventorybackup.txt. Thus, the syntax is cp file1 file2. Here, file1 is the name of the file you want to copy and file2 will be the name of the file when it is copied to the current directory. Remember, the original file is never hampered in this case.


This is a multipurpose command. It can be used not only for moving the file, but also for renaming it. Suppose you want to move the file inventory.txt created in the directory abc to your current directory, then all you need to do is mv /abc/inventory.txt .. The dot (.) at the end indicates current directory. When using this, you will be left with just one file. This does not copy the file, but moves it from one location to another. Now, suppose that we have the file abc.txt, in your current directory. On typing mv abc.txt def.txt, the file abc.txt will be renamed to def.txt.


This is used to remove or delete a file. So, if you type rm abc.txt, the file will be permanently deleted from the system.


This has a working similar to that of rm. But, it is used for removing or deleting directories. So, on typing rmdir abc, you can delete the directory abc forever.

File Content Viewing


It can be used for creating and viewing the contents of a file. Suppose you want to view the contents of the file abc.txt, then you can type cat abc.txt. On typing this, you will get the contents of the file abc.txt displayed on your screen. If the file abc.txt does not exist, then it will be created on typing the command.


Using this, you can see the information in a file, one page at a time. This should be used if the file contains large content. For example, typing less abc.txt, will display the contents of the file abc.txt, one page at a time.


This is used to display the first ten lines of any file on your screen. If you type head abc.txt, then what you get on the screen are the first ten lines of the file abc.txt.


It works similar to head. But here, the last ten lines of the file can be viewed. So, typing tail abc.txt will present you with the last ten lines of the file abc.txt.

Using Wildcards

Asterisk (*)

The asterisk sign is one of the wildcards that you can use in any Unix command. To understand the application of the wildcards, let us take an example. Suppose you want to list out all the files that end with the word 'old'. Here, in this case if you type ls *old, then all such files that end up with the word old, like fold, gold, etc., will be listed.

Question Mark (?)

The question mark can replace just one character. So, if you want to list all the filenames that end with the word uzzle and have only one starting letter, then you can type ls ?uzzle. So, all the files containing uzzle, like puzzle, buzzle, etc., if present in that directory, will be listed.



This is one of the most commonly used ones. It displays the value of any variable. For example, if there is a variable $printer (all variable names in Unix start with the $ sign) and it has the value Cannon, then on typing echo $printer, Cannon will be displayed on the computer screen.


You can simply type man followed by the command name, to display the manual of all command. You will get all the information including the switches that you can use along with the command to further enhance your execution.


On simply typing whatis followed by the name of command, you will get the basic working of any command.



You can use this to check the list of processes and their process ids that are running in your computer system. A process id is a number that is used for the identifying processes and is unique for each process.


It is used to terminate any process that is being executed. It is similar to 'end task' that we use in windows. Here, we have to use kill followed by the process id or pid, i.e. kill pid. For example, if we want to kill the process cat, which has a pid 1134, then we will simply type kill 1134 in our prompt.


This is one of the most important commands used for file security. For understanding its use, let us try to gauge a few options that it provides. The priority and rights of a file depends on the three basic types of users. The owner user (u), the group(g), and other(o). Read, write, and execute permissions are given to each user. The execute permission is represented by the number 1, the write by the number 2, and read by 4. Now, suppose the user or the owner of the file, abc, has all the three permissions, then he will have a total permission number of 7 (4+2+1). Now, if the group users have just read permission then their total permission number will be 4 (4+0+0). And suppose the other users only have the permission to execute the file, then they will have a total permission of 1 (0+0+1). So, the permission associated with the file will be 741. Changing this permission will result in changing the user rights to the file. So, in the same example, if we want to change the permission of the user to just read and write, and the group and other user to just execute, then we will execute the command as chmod abc 611. The other way is that you can remove the execute rights of the user by typing chmod abc u-x. For adding read and write permission to the group and other users, you can type chmod abc go+rw. Remember, only the owner of the file has the right to use the chmod command on the file.

All the Unix commands explained above have a list of options or switches, that can be used along with them. There are a many more commands, which you can use and study when you go for an in-depth study of this wonderful operating system. The ones explained above will help you learn the OS and use it more efficiently. By simply using them, you can not only learn Unix, but understand the fundamentals of operating systems. All the different types of operating systems are based on the same basic principles as that of Unix.