Linux uses the command line interface (CLI) for commands that can perform various tasks. Because the Linux command line uses text it can perform actions very quickly which is why even in the 1970s Computers using the Linux command line would operate quickly and efficiently. It may seem challenging for a beginner which is why it is important to start with the most basic commands and progress from there. The Linux terminal can do many things like downloading a program from the internet or changing the name of a file. A Linux terminal can do a lot of what a regular desktop Linux OS can do but it can also quickly perform other various tasks which is a big reason as to why the command line is still widely used today. When using the command line it is important to know that you must be very careful because it is possible to make a mistake and impact your system.

You can access the terminal by going into the system tools folder. It is usually easy to find. The picture above is what a Linux command line will usually look like. The colors may be different but more less they are all similar. In the example above, John is the name of the user and doe is the name of the system. The ~ followed by the $ represents the home directory. These Linux commands are the most useful for beginners as well as experienced users. You can use these commands in your terminal for practice. All of these commands are safe to use but to get a better idea it is recommended to look up YouTube videos of Linux commands to see them live in action as well as other written tutorials. It will take a little while to get used to but tutorials like this will help you put it all together.

sudo

The sudo command stands for super user do. It is almost always installed on most Linux distros but if not you can use sudo apt-get install sudo or yum install sudo if using CentOS or Fedora. It is often used when installing or running a program which will then ask for the password of the root user. Using sudo is generally more secure then logged in as root.

sudo -s

This allows the user to log in as root. It is not recommended to log in as root unless you know what you are doing since it can be risky.

apt-get

apt-get stands for Advanced Packaging Tool and as the name implies it is used when installing and removing packages as well as clearing the system of cached data. Instead of using sudo apt-get to work with packages you can shorten it to sudo apt which most Linux distros will support. With these apt-get commands type the package name after the last word of the command. For example, sudo apt-get install packagename. The package name has be typed correctly in order to work. You can go to the package manager and look for the exact package name. For example the name of the Google Chrome browser package is chrome-browser-stable so each package name may be different.

sudo apt-get install

Installs a package

sudo apt-get remove

Removes a package.

sudo apt-get purge

Removes a package with configuration

sudo apt-cache search

Searches for a program

sudo apt-cache show

Shows package details

sudo apt-get update

Refreshes repository index but does not install or remove packages. This is a good command to use before using the sudo apt-get upgrade command.

sudo apt-get dist-upgrade

Upgrades packages and also ones with auto-handling of dependencies. The full-upgrade command also does the same thing. This command updates the system but could possibly remove packages in order to do that. It usually doesn’t but just in case it is possible to avoid this command completely.

sudo apt-get upgrade

Upgrades all up-gradable packages.

sudo apt-get autoremove

Removes all unwanted packages.

sudo apt-get clean

Clears out the local repository of received package files.

sudo apt-get autoclean

Similar to clean, autoclean Clears the local repository of retrieved package files but only removes files that can no longer be downloaded and are virtually useless.

ls

The ls command stands for list directory contents which lists the sub directories and files of the current directory. You can ls commands to list contents of any directory that you switch to.

ls -l

ls -l is similar to ls but instead lists the contents in long listing fashion which basically means that more info is provided like dates, size, and other info.

ls -a

The ls -a command lists all files including hidden ones. A file can be hidden by putting a . before the file name.

ls -la

The ls -la command lists all the sub directories and files as well as hidden files of the current directory. A lot of users will use this command since it lists the most content inside of a directory.

cd

The cd command (change directory) changes the current directory that the user is inside of. If you want to change a directory within your current directory type cd nameofdirectory such as pictures, downloads, music, or other directories. If the directory is located outside of the current directory you need to use a / to indicate the path. For example, cd /directory/directory To go back a directly use cd. with a single dot or cd.. (double dots). If the name of a folder or file within your directory has a space between it use a backwards slash like so, cd class

otes otherwise it will display an error because the space makes the command pick it up as two separate files resulting in an error. Also remember that Linux is case sensitive so the directory or file must be exact.

cd ~

This command allows you to go back to the home directory.

touch

The touch command creates a new file within a directory.

pwd

pwd stands for Print Working Directory which as the name implies, prints the path of the current working directory starting from the root.

mv

The mv command stands for move which is different from copy since it moved the file or directory to another location unlike copy which leaves the source file or directory where it was originally located.

cp

The cp command stands for copy which copies a file or directory to another location. In order to copy files and directories you must have permissions for the read source and write destination otherwise you will be denied permission.

mkdir

The mkdir (make directory) command creates a new directory.

rm

rm stands for remove which removes a directory or file. It should be used with caution. It may seem obvious to not delete an important file on purpose but is stated as a reminder just in case one starts using the rm command as practice. rmdir can also be used but can only remove a directory without files which makes rm usually more useful. If you want to use delete just the directory and not the files then use rm -r

locate

The locate command as the name implies locates a file.

cat

The cat command creates a file with content. This similar to the touch command but the difference is that the touch command creates an empty file.

clear

The clear command clears the terminal for a new start like it was just opened. This is useful if you simply want a new start which is easier than closing and reopening the terminal.

who

The who command allows you to see the users that are logged into the system. The whoami command is also a command that can be used but only displays the currently logged in user. For Just 1 personal computer this is almost always the same result but for a system of computers it can be different.

df

df stands for Disk free which is similar to du.

du

The du command stands for Disk Usage is used to estimate hard drive space. du is used more often than df.

hostname

hostname is a command which shows the users host name and domain name (DNS)

uname -a

uname is the regular command but the reason why I only listed uname -a is because with the -a parameter it will show all the system information instead of only parts of information.

killall

The killall command kills all running processes. This should not be used unless needed since data from a program can be lost. For example if a Web browser is misbehaving and is freezing the killall command can be used. You can also go to task manager, find the process, right click on it, then choose kill process.

lsblk

The lsblk command displays all block devices such as USB drives, hard drives or CD rom drives.

lsblk -l

The same as the lsblk command but instead lists it in long listing fashion which displays more information.

man

Displays a manual for any command used on Linux. For example type man ls, man sudo, man apt-get, or others to get a text manual description within the terminal on how the command works. Use the arrow keys to navigate the man page, enter to move one line at a time, space bar to go to the next page, and b to go back to the previous page. To quit the man page press the q key.

help

help is similar to the command man but displays different information on how to use the command. Type the name of the command before help

ping

ping stands for Internet Packet Groper which is used to check the network connection between a server and a host. For example type or paste a URL after the word ping and you will get a response from the server which including a lower or high ping time indicating if the website is online and how fast the response time is. Use ctrl+c to stop sending packets or x out of the terminal. Using ctrl+c is in theory the safer method.

So one thing to remember is to not be overwhelmed thinking that you have to remember every command. A lot of experienced Linux users don’t use every single command and again, most of the commands are performing tasks that can usually be performed within the graphical desktop OS. As stated in the beginning it is a good idea to look up other info and YouTube videos to see these commands in action like. For example Ifconfig and a lot of other advanced networking commands were not listed due to the fact that they can be confusing for a beginner so seeing them used in action can make them a lot easier to understand. The important part is to not feel overwhelmed which will makes things easier.

Share this: Twitter

Facebook

LinkedIn

Like this: Like Loading... Related