Updated July 11, 2023
Introduction to Unix Commands
The following article provides an outline for Unix Commands. An operating system offering both Graphical User Interface (GUI) and Command Line Interface (CLI) based interaction developed by Dennis Ritchie, Ken Thompson, Brian Kernighan, Joe Ossanna, and Douglas Mcllroy at Bell laboratory in the year 1970 known as a multi-tasking operating system allowing multiple users to work on the operating system simultaneously and provides commands for the users to interact with the application through Command Line Interface (CLI) like ls command, clear command, mkdir command, rmdir command, cat command, vi commands, rm command, mv command, su command, chmod command, sudo command, etc. which can be used to perform complex tasks.
What is Unix?
Unix is an operating system that offers both GUI and CLI-based interaction. Dennis Ritchie developed the C language. Unix is a multitasking operating system that also provides an opportunity for multiple users to utilize its feature. In simple terms, it’s also a multiuser operating system. Ubuntu operating system, which allows us to perform all the tasks traditionally associated with Unix, is a Unix-based version.
Professionals working with servers and individuals learning about command-line-based operating systems prefer it. Several complex and large applications use Unix to run due to its feature to manage the processes easily. Compared with the Windows OS, it is a bit fast and offers a good user experience.
1. Ls Command
This Unix command shows all the files and folders at your current location. The blue text just before the dollar sign indicates the current location or directory in the command-line interface. Here the current location is the Desktop.
2. Clear Command
The command used to clear the screen is “clear”. It doesn’t delete anything written on the screen but makes the current line look like the first line.
The below picture shows the before and after images while using the clear command.
3. Mkdir Command
This Unix command makes a new directory at your current location. In the below image, we are at the Desktop and using the mkdir command to create a directory named “newdir” there. The directory is typically displayed in blue color.
4. Rmdir Command
The command used to remove a directory is “rmdir”. In the below image, you can see that in the second line, the newdir is present, but after we executed the rmdir command, it deleted the newdir folder.
5. Cat Command
Cat command is used to read the data written on any file. You can use the command to append data to a file and overwrite its contents as well. We have seen that we have a file names test.css in the desktop location. Let’s use the cat command to display the contents of the file.
6. Vi Command
Vi command is the most useful command used to fetch the data written on any file on the terminal and let us make the changes simultaneously. Regardless of the size and type of the file, we can edit those using the Vi command if they have text written on it. Here we will add extra data in the test.css file.
7. Rm Command
The rm command is used to delete the files at your current location. In our case, we are at the Desktop with the test.css file; Now, we will try to delete that file using the rm command. The second line shows test.css present there, but after running the rm command, that file has been removed.
8. Mv Command
The mv command can be used for two purposes, for renaming and for moving files or folders. Here we will rename the page.html file to newpage.html. Please note that if you try to move the file to the same folder, it will rename it; if you try to move it to another directory, it will get moved there.
9. Su Command
Su command is used when we need to switch the user. In the picture below, we can observe that the current user is Vishal. Once the “su” command is used to log in as the root user, the username will indeed change. The red text on the left side of the dollar sign displays the username.
10. Chmod Command
We use the chmod command to change the permissions of a file. Here we have the newpage.html file. The file has read and run permission to the owner, the group, and others. We will use the chmod command to give all permission to everyone.
11. Sudo Command
Only the root user has the authorization to execute certain commands. Here we will be executing a command that could lead to making some changes in the system, and hence it couldn’t be executed with other users. We have to use the Sudo command to make it work.
Tips and Tricks to Use Unix Commands
Despite the limited number of commands, they can be utilized with multiple arguments to accomplish complex tasks. For instance, you can use the ls command to check the available files and directories at your current location. Additionally, using the -an argument with ls can reveal all the hidden files at the same location.
Every command has some arguments allocated to it that could be used with those particular commands. To check which arguments are for any specific command, you can use –help the argument. In the below image, we will see all the arguments that could be used with the chmod command. The keywords or arguments must be followed by — while writing in the command line.
Conclusion – Unix Commands
Unix is an operating system popular for its command-line interface. It comprises numerous commands that facilitate users’ interaction with the hardware. The command in Unix is the mean of communication while working through the terminal. In addition to CLI, it also offers a graphical user interface that adds more beauty to the pre-existing features of Unix.
We hope that this EDUCBA information on “Unix Commands” was beneficial to you. You can view EDUCBA’s recommended articles for more information.