Want to learn simple and practical Linux terminal commands to take your Linux OS game to the next level? Read along in this epic tech guide from TechMende.com
Basic Linux Terminal commands help users execute tasks easily and effectively. It might take a while to remember some of the basic commands, but nothing is impossible with lots of practice.
Thanks to a “shell” such as can be found in Linux operating systems, you can execute many useful commands via a command line and also open programs via text commands.
There are commands for different functions.
Many of the commands can also be expanded or have to be supplemented by further parameters that make the command unique.
The possibilities can be a bit overwhelming, especially for a Linux beginner, but with an overview of the most important commands you will certainly quickly familiarize yourself with the exciting function.
You can assign tasks and open applications to Linux using a line of text.
Some commands need to be expanded to be unique.
For example, you can use the “copy” command, but you must also specify what is to be copied.
To do this, first enter the file name and then select the directory into which the file is to be copied.
The command for copying the “techmende.txt” file to “Documents” could then look like this: “cp -u techmende.txt /Documents/files.txt”.
The exact commands may sometimes differ depending on the Linux operating system – such as Ubuntu – or may not be installed on the system at all.
List of Fundamental Linux Terminal Commands (CHEAT SHEET)
In this Linux Terminal Commands Cheat Sheet, the functionality of any given command is given after the hyphen.
1. pwd command – Finding Your Current Working Directory
Use the pwd command to find out the path of the current working directory (folder) you’re in. The command will return an absolute (full) path, which is basically a path of all the directories that starts with a forward slash (/). An example of an absolute path is /home/username.
To navigate through the Linux files and directories, use the cd command. It requires either the full path or the name of the directory, depending on the current working directory that you’re in.
Let’s say you’re in /home/username/Documents and you want to go to Photos, a subdirectory of Documents. To do so, simply type the following command: cd Photos.
3. ls command – View Directory Contents
The ls command is used to view the contents of a directory. By default, this command will display the contents of your current working directory.
If you want to see the content of other directories, type ls and then the directory’s path. For example, enter ls /home/username/Documents to view the content of Documents.
4. cat command – List File Contents on Standard Output
cat (short for concatenate) is one of the most frequently used commands in Linux. It is used to list the contents of a file on the standard output (sdout). To run this command, type cat followed by the file’s name and its extension. For instance: cat file.txt.
5. cp command – Copying Files in Linux
Use the cp command to copy files from the current directory to a different directory. For instance, the command cp oletompo.jpg /home/username/Pictures would create a copy of oletompo.jpg (from your current directory) into the Pictures directory.
6. mv command – Move Files
The primary use of the mv command is to move files, although it can also be used to rename files.
The arguments in mv are similar to the cp command. You need to type mv, the file’s name, and the destination’s directory. For example: mv file.txt /home/username/Documents.
7. mkdir command – Make a New Directory
Use mkdir command to make a new directory — if you type mkdir Classwork it will create a directory called Classwork.
8. rmdir command – Delete Directory
If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.
9. rm command – Delete Directories and Contents
The rm command is used to delete directories and the contents within them. If you only want to delete the directory — as an alternative to rmdir — use rm -r.
10. touch command – Creating a New Blank File
The touch command allows you to create a blank new file through the Linux command line. As an example, enter touch /home/username/Documents/DonaldTrump.html to create an HTML file entitled DonaldTrump under the Documents directory.
11. locate command – Locating/Searching for a File
You can use this command to locate a file, just like the search command in Windows. What’s more, using the -i argument along with this command will make it case-insensitive, so you can search for a file even if you don’t remember its exact name.
To search for a file that contains two or more words, use an asterisk (*). For example, locate -i class*members command will search for any file that contains the word “class” and “members”, whether it is uppercase or lowercase.
12. find command – Locating Files/Folders in a given Directory
Similar to the locate command, using find also searches for files and directories. The difference is, you use the find command to locate files within a given directory.
For example, find /home/ -name members.txt command will search for a file called members.txt within the home directory and its subdirectories.
13. grep command – Searching Text Contents in a File
Another basic Linux command that is undoubtedly helpful for everyday use is grep. It lets you search through all the text in a given file.
To illustrate, grep Dallas USA.txt will search for the word Dallas in the USA file. Lines that contain the searched word will be displayed fully.
14. sudo command – Gain Admin or Root Privileges
Short for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions. However, it is not advisable to use this command for daily use because it might be easy for an error to occur if you did something wrong.
15. df command – Checking Diskspace Usage
Use df command to get a report on the system’s disk space usage, shown in percentage and KBs. If you want to see the report in megabytes, type df -m.
16. du command – Check how much space a file/folder takes
If you want to check how much space a file or a directory takes, the du (Disk Usage) command is the answer. However, the disk usage summary will show disk block numbers instead of the usual size format. If you want to see it in bytes, kilobytes, and megabytes, add the -h argument to the command line.
17. head command – Viewing the 1st Lines of any Text File
The head command is used to view the first lines of any text file. By default, it will show the first ten lines, but you can change this number to your liking. For example, if you only want to show the first three lines, type head -n 3 filename.txt.
18. tail command – Viewing the Last Lines of any Text File
This one has a similar function to the head command, but instead of showing the first lines, the tail command will display the last ten lines of a text file. For example, tail -n filename.txt.
19. diff command – Compares Contents of 2 Files Line by Line
Short for difference, the diff command compares the contents of two files line by line. After analyzing the files, it will output the lines that do not match. Programmers often use this command when they need to make program alterations instead of rewriting the entire source code.
The simplest form of this command is diff file1.ext file2.ext
20. tar command – Archiving Multiple Files
The tar command is the most used command to archive multiple files into a tarball — a common Linux file format that is similar to zip format, with compression being optional.
21. chmod command – Changing RWX (rwx) Permissions
chmod is another Linux command, used to change the read, write, and execute permissions of files and directories. As this command is rather complicated, you can read the full tutorial in order to execute it properly.
21. chmod command
chmod is another Linux command, used to change the read, write, and execute permissions of files and directories. As this command is rather complicated, you can read the full tutorial in order to execute it properly.
23. jobs command – Display Current Jobs with their Statuses
jobs command will display all current jobs along with their statuses. A job is basically a process that is started by the shell.
24. kill command – Terminate Unresponsive Programs
If you have an unresponsive program, you can terminate it manually by using the kill command. It will send a certain signal to the misbehaving app and instructs the app to terminate itself.
25. ping command – Check Server Connection Status
Use the ping command to check your connectivity status to a server. For example, by simply entering ping google.com, the command will check whether you’re able to connect to Google and also measure the response time.
26. wget command – Download Internet Files
The Linux command line is super useful — you can even download files from the internet with the help of the wget command. To do so, simply type wget followed by the download link.
27. uname command – Print Detailed System Information
The uname command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel, and so on.
28. top command – List Running Processes and CPU Usage
As a terminal equivalent to Task Manager in Windows, the top command will display a list of running processes and how much CPU each process uses. It’s very useful to monitor system resource usage, especially knowing which process needs to be terminated because it consumes too many resources.
29. history command – Reviewing Your Previous Commands
When you’ve been using Linux for a certain period of time, you’ll quickly notice that you can run hundreds of commands every day. As such, running history command is particularly useful if you want to review the commands you’ve entered before.
30. man command – Display Command Manuals
Confused about the function of certain Linux commands? Don’t worry, you can easily learn how to use them right from Linux’s shell by using the man command. For instance, entering man tail will show the manual instruction of the tail command.
31. echo command – Moving Data into a File
This command is used to move some data into a file. For example, if you want to add the text, “Hello, my name is John” into a file called name.txt, you would type echo Hello, my name is John >> name.txt
32. zip, unzip command – Archiving and Extracting Files
Use the zip command to compress your files into a zip archive, and use the unzip command to extract the zipped files from a zip archive.
33. hostname command – Identify Host/Network Name
If you want to know the name of your host/network simply type hostname. Adding a -I to the end will display the IP address of your network.
34. useradd, userdel command – Creating & Deleting a User
Since Linux is a multi-user system, this means more than one person can interact with the same system at the same time. useradd is used to create a new user, while passwd is adding a password to that user’s account. To add a new person named John type, useradd John and then to add his password type, passwd 123456789.
To remove a user is very similar to adding a new user. To delete the users account type, userdel UserName
Linux Terminal Commands: Bonus Tips and Tricks
Use the clear command to clean out the terminal if it is getting cluttered with too many past commands.
Try the TAB button to autofill what you are typing. For example, if you need to type Documents, begin to type a command (let’s go with cd Docu, then hit the TAB key) and the terminal will fill in the rest, showing you cd Documents.
Ctrl+C and Ctrl+Z are used to stop any command that is currently working. Ctrl+C will stop and terminate the command, while Ctrl+Z will simply pause the command.
If you accidental freeze your terminal by using Ctrl+S, simply undo this with the unfreeze Ctrl+Q.
Ctrl+A moves you to the beginning of the line while Ctrl+E moves you to the end.
You can run multiple commands in one single command by using the “;” to separate them. For example Command1; Command2; Command3. Or use && if you only want the next command to run when the first one is successful.
Other Important Linux Terminal Commands
- “Whoami” – the question “Who am I?” Arises when different users are set for the system.
- “Df” – With this command you can quickly and easily see your hard drives and the used and available space on your system.
- “Rm” – With this command and a filename after it, you delete a file or directory.
- “Clear” – If you’ve tried around on the command line, a lot of text is displayed that you can clear with this simple command.
What are your favorite Linux terminal commands? Share with us below.