What Is Linux Command Line?

The Linux command line is just the Windows command line, which is a text interface on your computer. The Linux command line is also knowns as the shell, terminal, console, prompt, or other names you may know.

If you are a beginner, you may think the Linux command line is difficult from its appearance and it is confusing to use. However, you should know that the ability to copy and paste commands from a website, and the combination with the power and flexibility the command line offers means it is essential to use the Linux command line.

You can find the instructions to use the command lines on the internet. In this post, NewsPivot will walk you through how to use command lines on Linux.

How to Open a Terminal on Linux?

Like other operating systems (like Windows), there is more than one way to open the terminal on Linux. We will introduce 3 easy ways to access the terminal interface on Linux.

Way 1: Open a Terminal from Activities

On Ubuntu 18.04, you can click the Activities item at the top left of the screen, and then type terminals, command, prompt, or shell into the pop-up search box to find a launcher for the terminal.

Here you can see that the developers have design the terminal launcher with all the most common synonyms. So, it is easy to find and open the terminal using this method.

On other Linux versions or Ubuntu flavors, you can also find a terminal launcher, which should be located in the same place as other app launchers. For example, it may be hidden in a submenu. Or, you may have to search for the terminal from within the launcher. You can keep reading to find more ways to open a terminal on Linux.

Way 2: Open a Terminal Using Keyboard Shortcut

If you just want to use a quick way to bring up a terminal on Linux, you can use a keyboard shortcut combination. Most Linux systems use the same default keyboard shortcut to start a terminal: Ctrl-Alt-T. You can just press these 3 keys at the same time to call out a terminal.

Way 3: Open a Terminal Use the Dash Button

You can also go to the app menu to find and open the terminal. Here is how to do this on your Linux computer:

Step 1: Click the Show Applications icon from the Dash bar.

Step 2: You can see all applications that have been installed on your device. Go to find the Terminal icon and open it. If there are so many apps on the list, you can use the search function to directly locate it.

Here are the 3 ways to call out a terminal on Linux.

The Linux Commands for Beginners

First, let’s try some simple commands in the terminal:

You need to click the mouse into the terminal window to ensure that the keystrokes is in the terminal. Next, type pwd (all in lower case) in the terminal and press Enter or Return to run this command.

Then, you can see a directory path printed out like /home/YOUR_USERNAME.

Next, we will introduce some commonly-used Linux command lines.

#1. The ls Command

The ls command can list files and directories in the current working directory. It is the most commonly used Linux commands so far as we know.

After you run the ls command in a terminal, you can see all the files and directories in the directory. It offers a flexibility when displaying the data in the output.

#2. The pwd Command

The pwd command is used to print the current working directory on a terminal. This is a very basic command and you can use it easily solve the purpose very well.

This command has another purpose: enable you to find the directory where the scripts has been saved when you are creating scripts.

#3. The cd Command

When use command lines in a terminal on Linux, it is necessary to move around within directories. This time, you must know the cd command, which can help you navigate through directories.

Well then, how to use this command on Linux? You just need to type cd followed by directory like this: cd <directory path>.

#4. The mkdir Command

With the mkdir command, you can create directories from within the terminal.

#5. The cp and mv commands

The cp and mv commands are the same to the copy-and-paste and cut-and-paste commands in Windows. However, Linux doesn’t have a command to rename files, you can also use the mv command to rename files and folders.

#6. The rm command in Linux

You can use the rm command to delete files and folder. This is also one of the most important commands on Linux.

#7. The touch Command

The touch command is used to create an empty file or updates the timestamp of an existing file. Just try it when necessary.

#8. The ln command in Linux

If you want to create a link to another file, you can use the In command. If you are a Linux administrator, you must be familiar with this command.

#9. The clear Command

The clear command in Linux can clear the terminal screen. To be specific, you can run it in a terminal to remove all the text and output currently displayed. Then, you can start a work as a new interface.

#10. The cat, echo, and less Commands

The cat or echo commands can help you output the contents of a file or print anything to the terminal output

When the output printed by any command is larger than the screen space and needs scrolling, you can then run the less command. This command can break down the output and scroll through it with the use of the Enter or Space keys.

#11. The man Command

The man command is used to show the manual page for a specific command. After running it in a terminal, you can see the detailed information about the command, including the syntax, options, and examples.

#12. The uname and whoami Commands

The uname and whoami commands is just like the whoami command in Windows. You can run it to see the basic information that comes in handy. This command is especially useful  when you work on multiple systems.

Here are some flags that can be used with the uname command:

  • Use uname -s: display the kernel name.
  • Use uname -n: display the hostname.
  • Use uname -r: display the kernel release.
  • Use uname -v: display the kernel version.
  • Use uname -m: display the machine hardware name.

#13. The tar, zip, and unzip Commands

The tar command on Linux is used to create and extract archived files. You can even use this command to extract multiple different archive files.

If you want to create an archive, you need to use the tar command with the -c parameter. If you need to extract an archive, you need to use the command with the -x parameter.

As the commands say, you can use the zip and unzip commands to zip and unzip archive files. You can even use these two commands without any parameters.

#14. The grep Command

The full name of the grep is global regular expression print. This command is a versatile text search tool on Linux. You can run this command to search for specific patterns or strings in one or more files and filter the output of other commands.

#15. The head and tail Commands

When you want to output large files, you can try the head and tail commands on Linux. These two commands can show the beginning or the end of a file. You can run it  to quickly view a file’s content without opening it.

By default, you can see the first 10 lines of a file by using these commands. If you want to see a different line, you can use the command with the -n option.

#16. The diff, comm, and cmp Commands

If you want to compare files on Linux, you can use the diff, comm, and cmp commands. These commands can identify differences between two files, merge changes in the files, and perform other file comparison purposes.

The cmp command can compare two files and show the first byte that is different between them. You can also run this command to identify differences between binary files or to check for corruption in files.

#17. The sort Command

The sort command can sort lines in ascending or descending order and to perform other sorting operations. For example, you can run this command to soot by fields or using a custom sorting order.

#18. The export Command

The export command can set environment variables, which are used to save information that can be used by processes or commands.

#19. The ssh Command

The ssh command on Linux can create a secure shell connection to a remote server. This command also provides a secure encrypted connection between the local and remote servers. Thus, you can safely run commands and transfer files.

#20. The ps, kill, and killall Commands

The ps, kill, and killall commands can manage processes in Linux.

For example, you can run the ps command to display information related to the processes that are running.

If you want to end a process, you need to run the kill command followed by the PID (Process ID).

However, if you don’t know the process ID, you can try to end the process with its name by running the killall command.

#21. The df and mount Commands

The df and mount commands are used to mount filesystems and view the details of the file system.

For example, you can run the df command to view the amount of used space and available space on your hard disk. With the mount command, you can mount a file system or a device to a specific directory.

#22. The chmod and chown Commands

You can run specific commands like chmod and chown to modify file permissions and ownership on your Linux computer.

For example, the chmod command can change the permission of a file or directory. While the chown command can change the ownership of a file or directory.

#23. The ifconfig and traceroute Commands

The ifconfig and traceroute commands manage network interfaces and trace the route of network packets in Linux.

If you want to view all the network interfaces and the IP addresses & MAC addresses, you can run the ifconfig command.

You can use the traceroute command to trace the route of network packets and determine the path they take to reach a specific destination.

#24. The wget Command

Believe it or not, you can also use a command to download a file in the terminal. The wget command is what you need to run in a terminal.

#25. The ufw and iptables Commands

Like Windows, the Linux system also has firewalls. To manage firewalls, you can run the ufw and iptables commands on Linux.

#26. The sudo Command

The sudo command is very important for Linux users. This quote appears when a sudo-enabled user first uses the sudo command to obtain elevated privileges. Essentially, this command functions like logging in as the root user, depending on the permissions granted to the sudoer.

#27. The dd Command

The dd command is designed to convert and copy files from different file systems. At present, this command is usually used to create bootable USB for Linux, but it also has other purposes. For example, it can also perform low-level copying and conversion of data.

#28. The whereis and whatis Commands

You can use the whereis and whatis commands to search for information about your desired programs and files.

To be specific:

The whereis command can locate the binary, source, and manual pages of a specific command or program, and the whatis command can display a short description of a command or program. Besides, this command can tell us what a command actually is.

#29. The top Command

The top command is like the task manager in Windows. It can display the real-time information about system processes and resource usage, such as CPU usage, memory usage, and process information.

#30. The passwd Command

You can also create a password for your user. Then, you can just run the passwd command in a terminal. If you have permissions, you can also set a password for another account on Linux.

Conclusion

The Linux command line might look confused at first, but it’s a powerful tool that can greatly enhance your computing experience. By learning some basic commands and how to open a terminal on Linux, you’ll find it is not difficult to manage files, run applications, and perform various tasks on your system.

  • linkedin
  • reddit