Useful Linux Terminal Commands you must remember on 2024

Linux Terminal Command is a set of instructions used to perform various tasks in a Linux operating system

On Linux, the command-line is a powerful tool. Once you understand how to use it, it’s possible to accomplish a whole lot of advanced operations really fast. Sadly, new users find the Linux command-line confusing, and don’t know where to start. In an effort to educate new users on the Linux command-line, we’ve made a list of 25 basic Linux terminal commands to remember. Let’s get started!

First of all To open the terminal, press Ctrl+Alt+T in Ubuntu, or press Alt+F2, type in gnome-terminal, and press enter.

 ls :

ls is the list directory command ls command can also be used to reveal hidden files with the “a” command line switch.

ls

ls -a

LS command

cd: 

cd command used to change directories in the terminal. And you can add “..” to go backwards up a directory

cd /path/to/location/

cd ..

 pwd: 

PWD command used to display the current directory in the Linux terminal

 pwd 

pwd command

mkdir: 

you can use mkdir command to create a make new directory or create a new folder. Also, use the “p” command line switch To preserve the permissions of the folder to match the permissions of the directory that came before it,

mkdir

mkdir -p name-of-new-folder

 rm:

rm command is used to remove, or delete a file from the command line, If you are looking to delete a folder use the “rf” command line switch.

rm /path/to/file

rm -rf /path/to/folder

Create and remove directory

cp:

To make a copy of a file or folder use cp command followed by the location of the file. And to copy a folder, use cp with the “r” command line switch

cp /path/to/file

cp -r /path/to/folder

mv: 

Using mv command you can do lots of things on Linux such as move files around to different locations or rename files. move a file from one location to another, try the following example.

mv /path/to/file /place/to/put/file|

If you looking for move a folder, write the location of the folder followed by the desired location where you’d like to move it.

mv /path/to/folder /place/to/put/folder/

To rename a file or folder, cd into the directory of the file/folder you’d like to rename, and then use the mv command, for example:

mv name-of-file new-name-of-file

mv name-of-folder new-name-of-folder

You can use the clear command to clear the terminal if it gets filled up with too many commands.

sudo — A widely used command in the Linux command line, sudo stands for “SuperUser Do”. So, if you want any command to be done with administrative or root privileges, you can use the sudo command.

touch — The touch command is used to create a file. It can be anything, from an empty txt file to an empty zip file. For example, “touch new.txt”.

history: Well, the history command Displays a list of all recently used commands.

cat: The cat command lets you view the contents of files in the terminal. Write the command out followed by the location of the file you’d like to view. For example cat /location/of/file

head: you can use the head command followed by the location of the file to view the top 10 lines of a file. here an example: head /location/of/file.

tail: The tail command followed by the location of the file used to display the bottom 10 lines of a file. tail /location/of/file

man & –help: To know more about a command and how to use it, use the man command. It shows the manual pages of the command. For example, “man cd” shows the manual pages of the cd command.

Typing in the command name and the argument helps it show which ways the command can be used (e.g., cd –help).

Ping:  The ping command is used to check the latency between your network and a remote internet or LAN server. for example, ping google.com  or ping IP address (192.168.1.1)

And to ping few numbers of times use c command line switch and a number. for example, if you want to ping a website 5 times then use the command ping google.com -c5

hostname: command used to know your name in your host or network. Basically, it displays your hostname and IP address. Just typing “hostname” gives the output. Typing in “hostname -I” gives you your IP address in your network.

uptime: command used to check how long your Linux system has been online,

uname: command can be used to view your current distribution codename, release number, and even the version of Linux you are using.

du: Command line used to view the space that a directory on your system is taking up

whereis: command used to track down the exact location of an item in the command line. For example, you can use whereis firefox command to find the location of the Firefox binary on your Linux system

locate: Command is used to Search for files, programs and folders on the Linux. Simply write locate command, followed by a search term. Example locate search-term

ps: command used to view current running processes directly from the Linux terminal,

curl: command used to download a file from the internet through the Linux terminal. Simply write the curl command followed by the file’s URL, the > symbol and the location you’d like to save it. For example: curl https://www.example.com/file.zip > ~/Downloads/file.zip

You can exit from the terminal by using the exit command.

Also, you can shut down or reboot the computer by using the command sudo halt and sudo reboot.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More