Basic Linux Commands
15 November 2024 at 15:08
- pwd β When you first open the terminal, you are in the home directory of your user. To know which directory you are in, you can use the βpwdβ command. It gives us the absolute path, which means the path that starts from the root. The root is the base of the Linux file system and is denoted by a forward slash( / ). The user directory is usually something like β/home/usernameβ.
- ls β Use the βlsβ command to know what files are in the directory you are in. You can see all the hidden files by using the command βls -aβ.
- cd β Use the βcdβ command to go to a directory. βcdβ expects directory name or path of new directory as input.
- mkdir & rmdir β Use the mkdir command when you need to create a folder or a directory.Use rmdir to delete a directory. But rmdir can only be used to delete an empty directory. To delete a directory containing files, use rm.
- rm β Use the rm command to delete a file. Use βrm -rβ to recursively delete all files within a specific directory.
- touch β The touch command is used to create an empty file. For example, βtouch new.txtβ.
- cp β Use the cp command to copy files through the command line.
- mv β Use the mv command to move files through the command line. We can also use the mv command to rename a file.
9.cat β Use the cat command to display the contents of a file. It is usually used to easily view programs.
10.vi - You can create a new file or modify a file using this editor.