Linux Terminal commands may give an impression of being complex to use for a beginner, but as you learn, you realize how easy, powerful, and effective they are. Tasks that could undergo multi-step processes through GUI can be executed quickly by typing commands into the terminal.
Are you looking forward to getting started with Linux systems? Below are 20 useful commands you can use to manage tasks in your system.
Useful Linux Terminal Commands for a Beginner
1. ls command
The LS (list file) command shows the files and folders present in the path provided. When executed alone without giving any path, the LS command will display the current working directory’s contents. This command can be combined with various options to provide a detailed output. To see these arguments execute the ls –help command.
ls [-options] [path]
Below is an illustration of the LS commands and the various options you can include.
2. pwd Command
The PWD (Print Working Directory) command is an environment variable that shows the current working directory path. PWD only supports two arguments: -L and -P.
- pwd -L: Shows the symbolic path
- pwd -P: Shows the actual path
Note: The two arguments L and P are executed in caps lock.
When executed without any of these arguments, PWD will print the actual path. Below is an example of the PWD command.
3. cd command
The CD (change directory) command is used to navigate through directories. To move to a directory-A, all you need to do is call the CD command and give the path to directory-A. When executed alone, the CD command will drop to the home directory. Below are some options you can use with CD command:
- cd /: This command will take you to the root directory.
- cd ..: This command will take you to the parent directory of the current directory.
- cd ~: This works similar to the CD command and will drop you to the home directory.
4. man command.
The man command shows the user manual of command right in the Linux shell. It prints detailed information about the command, including NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS, and more.
man [-options] [command]
5. mkdir command
The MKDIR command is used to create a new directory. If a path is not provided, the new directory will be made in the current working directory. mkdir command is also used to set user permissions on the directories created.
mkdir [-options] [directory-path-name]
6. locate command
The locate command is used to find files in the Linux system by name. It might sound similar to the find command but works better and faster. When a search is initiated, unlike the find command, which will go through the filesystem looking for that particular name, locate will look into the database. This database contains bits and parts of the file and their paths.
locate [-option] [pattern]
The echo command is used to print the text passed as an argument. It is mainly used in shell scripting and batch file processing. It prints the output on the terminal, but when used with the ‘>>’ argument, it can print the output to a file.
echo [-option] [text/string]
8. history command
When run in the terminal, the history command displays all the commands that were previously executed by the user.
9. ping command
The PING (Packet Internet Groper) command checks the connectivity status between the host to a server. Ping uses ICMP(Internet Control Message Protocol) and sends an ICMP echo to the server. It takes an input of an IP address or URL.
ping [-options] [URL/IP address]
10. sudo command
The SUDO (Super User DO) command enables the performance of a task that requires administrative privileges. Therefore, if you run a command and you get an output like “permission denied,” use the SUDO command as illustrated below.
11. wget command
The wget command allows you to download files from the internet. By typing wget followed by the download link initiates the download.
wget [-options] [URL]
12. kill command
The kill command terminates an unresponsive program manually by sending a signal that instructs the app to stop running. To view all signals that you can send, execute the command kill -l command. When executed without any option, the KILL command will send the default TERM signal, ‘Terminate.’
kill [-signal] [PID]
The clear command does away with all the clutter on the terminal, making it look like it has just been launched. It clears the Terminal screen.
14. top command
The TOP command is used to lists all running processes in the system.
15. head command
The head command shows the first N(number) of data in a file. If no options are specified, this command will print the first ten(10) lines in a file.
head [-options] [file-name]
16. tail command
The tail command is the direct opposite of the head command. It prints the last N(number) of lines in a file. If no option is provided, it will print the last ten(10) lines by default.
tail [-option] [file-name]
17. rm command
The rm (remove) command is used to delete files, folders, symbolic links, etc. from the file system. The rm command alone, however, cannot remove directories. To do so, you will need to use the ‘-r’ (recursive) option.
rm [-options] [file/folder-name]
18. rmdir command
The rmdir command deletes an empty directory from the system.
rmdir [-options] [directory-name]
19. mv command
The MV (move) command has two main functions:
- Rename files and directories
- Move a file from one location to another
mv [options] [file-name]
20. exit command
The exit command is used to exit the shell where it is currently running. It can also be used to close the Terminal window.
Those are 20 basic commands that would greatly help you manage and execute various tasks on your system. If you have any difficulties with a command, use the –help option or see the user manual with the man command.