Frequently Used Linux Commands for Beginners

There are very many commands you can find on a Linux system. In this guide, I will review frequently used Linux commands for beginners.

1. ls command

In Unix-based operating systems (like Linux and macOS), the ls command lists the files and directories in a given location. The command’s name is “list” and it’s used to show a directory’s contents.

Here is an example:

$ls
$ls  -l 
$ls  -a

2. cd command

The cd command can change the current working directory in a Unix or Linux operating system. The command’s syntax is as follows:

$cd  /directory/you/wish/to/cd/to

Example:

$cd /home/fossman/Documents/

3. pwd command

In command-line interfaces (CLI), the pwd command is used to print the current working directory or the directory in which the user is now residing. The system will return the complete path to the current working directory when you input pwd in the command-line interface and hit Enter.

$cd   /home/fossman/Documents/
$pwd

4. mkdir command

A new directory or folder can be created within the file system using the mkdir command in a command-line interface (CLI). The command’s syntax is as follows:

Example:

$mkdir   /home/fossman/Documents/projects

5. rmdir command

An empty directory can be deleted with the rmdir command in command-line interfaces like the Linux shell or Windows Command Prompt. The syntax of the command is:

$rmdir [options] directory

Example:

$rm  /home/fossman/Documents/projects/file1.txt

6. cp command

To move files or directories between locations in Linux/Unix, use the cp command. The cp command’s fundamental syntax is as follows:

$cp [options] source destination

Example:

$cp file1.txt  /home/fossman/Documents/

7. mv command

Files and directories can be moved or renamed using the mv command, which is a Unix/Linux shell operation. The command is written as follows:

$mv [options] source destination

Examples:

$mv  file1.txt   file2.sh
$mv  script1.sh  /home/fossman/Documents/projects/scripts/backup.sh

8. rm command

To remove or delete files or directories, use the Linux/Unix command rm. The basic syntax of the rm command is:

$rm [options] [file/directory]

Example:

$rm  /home/fossman/Documents/projects/scripts/backup.sh

Note: To remove directories, use the -f and -r flags, here is an example:

$rm  -rf  /home/fossman/Documents/certs

9. sudo command

Using the “sudo” command, users with the required rights can run a command as either the superuser or another user under Unix/Linux. “Sudo” is short for “superuser do.” When a user uses “sudo,” the system asks them to enter their own password to confirm their identity before executing the command with elevated privileges.

For instance, if a user has to install new software on their Linux machine, they may use the “sudo” command to execute the installation command as a superuser because only the superuser has the privileges required to install software on the system. The basic syntax for using “sudo” is:

$sudo [command to run]

Example:

$sudo apt update

10. cat command

The Unix/Linux command “cat” stands for “concatenate” in abbreviation. It is utilized to display in the terminal the content of one or more files.

$cat file.txt
$cat file.txt file2.txt

11. grep command

The grep command is a Unix/Linux program that searches for a given pattern in a file or series of files. Grep is an acronym that stands for “global regular expression print.” The basic syntax for using grep is as follows:

$grep [options] pattern [files]

Example:

$grep  “remote_host”  /home/fossman/Documents/projects/scripts/backup.sh

In this example, remote_host is the pattern being searched in the file.

12. chmod command

“chmod” is an abbreviation for “change mode,” and it is a Linux/Unix tool used to alter the permissions of files and directories.

$chmod  [options]  file/directory

Examples:

$chmod  +x /home/fossman/Documents/projects/scripts/backup.sh
$chmod  0775 /home/fossman/Documents/projects/scripts/backup.sh

13. chown command

The chown command is a Unix/Linux command that is used to alter the owner and/or group of a file or directory. The command stands for “change owner” and is generally used by system administrators to handle file ownership and permissions. The fundamental syntax for the chown command is as follows:

$chown [options]  [user]:[group]  file/directory

Example:

$chmod  www-data:www-data /var/www/html/
$chmod  root:root /var/backups/

14. ps command

The ps command is a popular tool in Unix-like operating systems such as Linux and macOS that allows users to examine information about the system’s presently executing processes. To examine your processes, you may run them without any settings like this:

$ps 

To watch root user processes, use the sudo command or ps from the root account:

$sudo ps

15. top command

The top command is a Linux/Unix program that monitors system processes and their resource utilization. When invoked, it gives a real-time view of the processes presently executing on the system, as well as their resource use, such as CPU and memory utilization. You may run top without any parameters, such as this:

$top

To view root user processes, use the sudo command or run top from the root account:

$sudo top

16 tar command

In Unix-based operating systems (such as Linux and macOS), the “tar” command is used to archive and compress files and directories into a single file. The word “tar” is an abbreviation for “tape archive,” which reflects the program’s historical roots as a utility for generating backups on magnetic tape. The tar command has the following basic syntax:

$tar [options] [archive-name] [file(s) or directory]

Example:

$tar -cvf fossman.tar /home/fossman/

17. wget command

wget is a command-line utility that is used to get or download files from the internet. The wget command has the following syntax:

$wget [options]  [URL]

Examples:

$wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
$wget -c https://dl.google.com/android/repository/platform-tools-latest-linux.zip

18. ssh command

The ssh (Secure Shell) command is a command-line utility for remotely accessing and managing servers, computers, and devices via a network. Users can use the ssh command to securely connect to a remote machine, transfer files, and run remote instructions. The following is the basic format for using the ssh command:

$ssh [options] [user]@[hostname]

Examples:

$ssh  fossman@10.10.2.2
$ssh -vv fossman@10.10.2.2

19. scp command

The scp (secure copy) command is a Linux/Unix command that is used to securely transfer files and directories between two remote destinations. To send files securely, it employs the Secure Shell (SSH) protocol. The following are the fundamental syntax for using the scp command:

$scp username@remote_host:/remote/file/path  /local/file/path
$scp /local/file/path username@remote_host:/remote/file/path

Example:

$scp  fossman@10.10.2.2:/home/fossman/bin/backup.sh   ~/bin/scripts/
$scp ~/bin/scripts/setup_acc.sh fossman@10.10.2.2:/home/fossman/bin/

20. ping command

The “ping” networking command is used to test the connectivity of two devices across an IP network, such as the Internet. Ping delivers an Internet Control Message Protocol (ICMP) echo request packet to a specified IP address and then waits for an ICMP echo reply packet. The command output displays the round-trip time for the echo request and reply packets, as well as additional statistics like packet loss.

Usage examples:

$ping 8.8.8.8
$ping www.google.com
$ping -c 4 8.8.8.8
$ping -c 4 www.google.com

21. ifconfig command

The ifconfig command is a network administration utility for configuring, controlling, and viewing network interfaces on a Linux or Unix system. It stands for “interface configuration” and is used to view or change the network settings for a network interface card (NIC) or network device.

ifconfig provides information about all active network interfaces on the system, including their IP addresses, netmasks, and hardware addresses, when run without any parameters. The output also contains information on the amount of data transferred and received on each interface.

$ifconfig

ifconfig can also be used to set up network interfaces, such as assigning IP addresses, configuring netmasks, creating routes, enabling or disabling interfaces, and modifying other network settings. However, these configuration activities typically necessitate root access. Overall, ifconfig is an efficient utility for managing and debugging network interfaces on a Linux or Unix system.

22. ip command

In Linux systems, the ip command is a versatile and powerful tool for managing network devices and routing tables. It is employed in the configuration, management, and troubleshooting of network interfaces and routing tables. Here is an example of how to use the ip command:

$ip add

Conclusion

These are only a few of the many commands available in Linux. In Linux, there are many more commands, each with its own function and syntax. To learn more about a command and its available options, visit its man page (man command).

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Page Contents