Menu
In the context of operating systems in general, and Linux in particular, the term “command” means either a command line application or functionality built into the user shell. However, to the end user, this distinction is of little consequence. Both are used in the same way. You input words into your terminal emulator, and it outputs the results.
HomePCLinux40 Essential Linux Commands You Should Know
The goal of this article is to list some commands every Linux user should know, or at least know of, in the case of those with a phobia of text-based interfaces. It doesn’t mean to list every useful command, it isn’t a list of the lesser known utilities, and it isn’t a manual. It aims for coverage of the most useful application in day to day life.
As such, it’s divided into several categories, corresponding to particular tasks. It presumes no particular distribution, and while not all the programs described will be installed by default in every distribution, most of them will be present, and the others can be found in the repositories.
Linux Commands For File System Management
1. ls
By default, list the contents of the current directory. If you provide it a path, it will list the contents of that. Useful options to know are -l and -a, a long list format with more information and show hidden (dot) files, respectively.
2. cat
If given a single file, prints its contents to the standard output. If you give it more than one file, it will concatenate them, and you can then redirect the output into a new file. Potentially useful is the -n option, which numbers the lines.
3. cd
Allows you to go from current directory to specified directory. Calling it without arguments returns you to your home directory. Calling it with two dots (cd .) returns you to a directory “above” the current one, while calling it with a dash (cd -) returns you to the previous directory, regardless of where it’s located relative to the current one.
4. pwd
Prints your current directory. Useful if your prompt doesn’t contain this information, and especially useful in BASH programming for obtaining a reference to the directory in which you’re executing the code.
5. mkdir
Create new directories. The most handy switch is -p, which creates the entire specified structure if it doesn’t exist already.
6. file
Tells you the type of a file. Since files in Linux aren’t under obligation to have extensions for the system to work (not that having extensions always helps), sometimes it’s hard for the user to know what type of file something is, and this little utility solves that problem.
7. cp
Copies files and directories. Since it doesn’t copy directories recursively by default, remember to use -r or -a. The latter preserves mode, ownership and time stamp info in addition to recursively copying.
8. mv
Moves or renames files and directories. Essentially, moving and renaming is one operation – renaming is just “moving” a single file to the same place under a different name.
9. rm
Delete files and directories. Certainly a very useful command to know, as you cannot remove clutter without it. However, beware when using it. Although nowadays you’d really have to work on it to cause some damage to the system, you can still damage yourself – rm doesn’t remove files to some imaginary wastebasket from which you can fish them out later when you realize you’ve made a horrible mistake, and “rm ate my homework” isn’t going to convince anyone. Deleting directories requires recursive operation, so once again we have the -r switch.
10. ln
Creates hard or symbolic links between files. Symbolic or soft links are sort of like Windows shortcuts, they provide a convenient way of accessing a particular file, though the analogy doesn’t quite hold – symlinks can point to anything, but do not feature any metadata. You aren’t very likely to ever use hard links, but knowing they’re aliases to files – as opposed to symlinks, which are aliases to file names – can’t hurt.
11. chmod
Change user permissions. This refers to viewing, writing and executing files. A normal user may change permissions for files he owns.
12. chown
Change file ownership. Only the root user may change the owner of a file. To recursively change the owner for all the files in a directory, use it with -R.
13. find
Search the filesystem for files or directories. Find is a very versatile and powerful command, not only because of its searching capabilities, but also because it allows you to execute arbitrary commands on matching (or non-matching, even) files.
14. locate
Unlike find, locate searches the updatedb database for file name patterns. This database contains a snapshot of the filesystem. This makes locate very fast, but also unreliable – it cannot tell whether anything changed since the last snapshot.
15. du
Show file or directory size. Among the more useful options are -h, which converts the reported sizes into a more human-friendly format, -s which gives only a summary instead of the whole listing, and -d which controls the depth of directory recursion.
16. df
Show disk usage. The default output is good enough – it lists every filesystem, reports its size and the amount of used and available space – but you might want to tack on -h, which once again provides a more human-friendly report.
17. dd
Convert and copy a file, according to its manpage. Not exactly the clearest or most useful description around, and yet, that’s all dd does. You give it a source and a destination, and optionally some other commands, and it copies from one to the other. Its power comes from the flexibility – you can tell it the exact block size, it can copy around corrupted data, and it isn’t picky about devices – if you want to overwrite your hard drive with zeroes straight from /dev/zero, you’re welcome to do it. It’s also commonly used for creating live USB sticks from hybrid ISO images.
18. mount / umount
This pair takes care of mounting and unmounting filesystems. This can range from USB sticks to ISO images. Usually only root has mounting privileges.
Linux Commands For Text Processing
19. more / less
These two similar utilities allow you to view text chunked into screenfuls. Imagine a very long output from some command. Perhaps you called cat on a file and your terminal emulator took a few seconds to scroll all the text. Well, if you pipe it into one of these, you can now scroll it at your leisure. Less is newer and offers more options, so there is no reason to use more.
20. head / tail
Another pair, but here both halves have their uses. Head outputs a number of the first (“head”) lines of a file, while tail outputs a number of last (“tail”) lines of a file. The default number is ten, but this can be controlled via the -n option. Another useful switch is -f, which is short for “follow”, which continually outputs any appended lines – so, for instance, if you wanted to monitor a log file instead of constantly opening and closing it, you could use “tail -f /path/to/logfile”.
21. grep
Grep, like all good Unix tools, does one thing, but does it well. It searches text for patterns. By default it looks at standard input, but you can specify files to be searched. A pattern can be a normal string or a regular expression. It can print out matching or non-matching lines, and their context. Every time you run a command which spews a lot of information you don’t need, pipe it into grep and let it do its magic.
22. sort
Sorts lines of text by various criteria. Among the more useful, there’s -n, which sorts by the numeric value of a string, and -r, which reverses the output. An example of where this might come in handy is sorting du output – for example, if you wanted to see the files sorted in descending order according to size, you’d combine the two options.
23. wc
The command line word counting utility. And line counting. And byte counting. And character counting.
24. diff
Shows the difference between two files via line by line comparison. It only shows altered lines, abbreviating changed as c, deleted as d and added as a.
Linux Commands For Process Management
25. kill / xkill / pkill / killall
All of these serve to “kill” a process, ie terminate it. The difference is what they accept as input. Kill wants the process ID, xkill allows you to click a window to close it, while killall and pkill accept the name of a process, but have somewhat different options and subtly different behavior. Note these do not belong to the same package, and xkill especially is not likely to be installed by default. We advise you to rectify that for your own convenience.
26. ps / pgrep
As mentioned, kill needs the process ID. One way to obtain this is by using ps, which prints information about the currently active processes. The default output is not hugely useful, so stick an -e there to see information about every process on the system. This is only a snapshot, it will not update, see top for that. The pgrep command works in the following manner: you give it a process name, it gives you the process ID. Partial matches count, so be careful.
27. top / htop
These two are similar, both display processes, and can be thought of as console system monitors. We recommend you install htop the first chance you get if your distribution doesn’t ship it by default, as it’s a much improved version of top. For starters, it’s not merely a viewer – it allows you to control processes via its user-friendly console GUI interface.
28. time
Time a process. Think of it as a stopwatch for program execution. Useful if you’re curious how much slower is your homework implementation of a sorting algorithm compared to the built-in one. Contrary to what you might expect based on the name, it doesn’t tell you the time. See date for that.
Linux Commands For BASH and User Environment
29. su / sudo
Su and sudo are two ways of accomplishing the same thing – running a command as another user. Depending on what your distribution is, you’ve likely seen only one or the other, but both are serviceable. The difference is that su switches you to a different user, while sudo only runs the command with another user’s privileges.
30. date
Unlike time, date does exactly what you’d expect it – it prints out the date (and time) to the standard output. The output itself can be formatted to your specification, and it takes everything from the usual stuff like year, month, day,
12 or 24 hour format to nanoseconds and the ISO week number. For example, date +”%j %V” would give you the day of the year followed by the ISO week number.
31. alias
This commands creates or changes aliases to other commands. What this means is, you can give names to new commands (or groupings of commands) or “rename” existing ones. It’s very handy for abbreviating long strings of commands you find yourself using often, or giving more memorable names to things you don’t use that often and have problems memorizing.
32. uname
Outputs some basic system information. By itself, it won’t give you anything very useful (“Linux”), but call it with -a, and it will provide kernel information, as well as tell you the hostname and processor architecture.
33. uptime
Tells you how long has the system been running. Not exactly essential information, but good for bragging rights and the occasional compute-things-relative-to-how-long-I’ve-been-at-the-computer situation.
34. sleep
You might be wondering why or how would this ever be useful, but even outside BASH scripts, it has its uses: for example, if you’d like to shutdown the computer after a certain period of time, or even as a makeshift alarm.
Linux Commands For User Management
35. useradd, userdel, usermod
These commands allow you do add, delete and modify user accounts. It’s not very likely you’ll be using these often, especially if you’re the sole user of your system, and even if not, you might opt for doing this via a GUI, but it’s good to know what they do and that they’re there in case you suddenly need them.
36. passwd
This command enables you to change your user account password. As root, you can reset normal user passwords, though you cannot view them. It’s a good security practice to change your password every so often.
Linux Commands Fro Help / Documentation
37. man / whatis
The man command brings up the manual for a particular command. Most command line applications come with a man page. Whatis provides a one line summary lifted from the relevant sections of the manual. What are sections of the manual? See for yourself with “man man”.
38. whereis
Tells you where an executable binary files lives, provided it’s in your path. It can also find its manual page and source code, provided they are present.
Linux Commands For Network
39. ip
If the list of network related commands seems awfully short, you’re probably not acquainted with ip. In short, the net-utils package which contains ipconfig, netstat and others has been deprecated in favor of the iproute2 package. It provides the ip command, which replaces ipconfig, netstat, route, etc. You could view it as a Swiss Army knife of networking, or a unwanted mess, but either way, it’s the future.
40. ping
Pings are ICMP ECHO_REQUEST datagrams, but that’s not important. The important thing is that the ping utility is a useful diagnostic tool. It allows you to quickly test if you’re connected to your router or the Internet, and gives some indication of the quality of that connection.
SEE ALSO: 10 Best Linux Desktop Environments
10 Free Online Resources for Learning Linux
Linux used to have a reputation of being complicated and hard to learn. You're probably familiar with the stereotype that only hardcore geeks could..
Linux vs Windows, As Experienced By A Linux User
If you've ever been to a tech-related online forum, chances are you've witnessed a thread called 'Linux vs Windows' or similar, where users of..
Canon Pixma G3010 Review: An Affordable, Feature Rich Ink Tank PrinterBlaupunkt BTW-01 True Wireless Earbuds Review: Good, but Difficult to RecommendNetgen Morgen Review: A Good Looking, Great Sounding Bluetooth Speaker
(12 votes, average: 5.00 out of 5)
Loading..
If you run a Linux distribution, and you are only using the GUI, you are missing out. The Linux terminal is an extremely powerful tool that goes well beyond the GUI. Writing commands might seem scary for a beginner, but you will soon get the hang of it. In this guide, you will find the most important Linux commands, to use the terminal like a pro.
Unblock any international website, browse anonymously, and download movies and Mp3 with complete safety with CyberGhost, just for $2.75 per month:
We have prepared this guide on Linux Mint 18.1 and Ubuntu 16.04 LTS.
The basic Linux commands, however, are universal, and they should work on any past and future distribution. They will even work with non-Linux operating systems based on Unix, such as FreeBSD, or the macOS / OS X terminal.
Table of Contents
Important information about the Linux terminal
There is not a single Linux distribution, as far as we know, that doesn't have a terminal of some kind. On the contrary, there are a few distributions that don't have a GUI by default, and everything is done on the command line.
To open a terminal quickly from the GUI, the shortcut Ctrl+Alt+T will work on most distributions and desktop environments.
This is the basic anatomy of most Linux commands:
Using sudo will run any command with administrative rights. Most Linux commands that have to deal with system files and installation/uninstallation of programs demand sudo.
The linux commands are case-sensitive
It is important to remember that everything written in the terminal is case-sensitive. When the command is 'sudo', neither 'Sudo', 'SUDO', nor 'sUdO' will work.
Most Linux commands are lowercase, but there are capitalized switches, such as 'chown -R'.
The file and directory names are also case-sensitive. 'File1' and 'file1' are different files, even if they are in the same directory.
Beware of spaces
Spacing is equally important. 'chown-R' will only return an error. If we want to create/access/delete a file or directory that has a space in the filename, we can either put the whole filename inside quotation marks..
..or 'escape' the space using the backslash '.
If we did neither, the particular mkdir command, which creates directories, would create two directories, 'Folder' and 'Name'. Other Linux commands would just fail.
Finding previous Linux commands
Pressing the Up keyboard key will cycle through the last Linux commands we successfully used, in order. No failed commands will show here.
We can also use the history command to see all the Linux commands we have ever used on the terminal.
The invisible password
When we are asked for our password, e.g. after we used 'sudo', as we type the password nothing will show on screen, no stars or dots or anything. We just type the password and press Enter.
If you want to change the default behavior and have stars appear while typing your password, check out our guide:
Use Tab to autocomplete
The Tab button on the keyboard is a huge time saver on Linux commands, as it will automatically fill in the names of files and directories.
If we want to delete a file named 'whydidIgivethisfilesuchalongname', we just need to type 'rm w' and pressing Tab will automatically complete the rest of the filename.
If there are more than files that begin with the same letters, e.g. 'whydidIgivethisfilesuchalongname' and 'whydidIeatsomuch', pressing Tab on 'rm w' will autocomplete the common 'whydidI'.
We then need to type an additional character - 'g' or 'e', in the example - and press again Tab for the autocompletion to resume.
Copying and pasting Linux commands
To copy or paste on the terminal, Ctrl+C and Ctrl+V won't work.
Instead, we must use Ctrl+Shift+C and Ctrl+Shift+V. Or we can right click and use the commands from the context menu.
Wildcards
While using Linux commands, the characters '?' and '*' are wildcards.
'?' will replace any single character. So, if we have two files names test1file and test2file, we can delete them both with 'rm test?file'. But this won't delete test12file.
'*' will replace any string of characters. 'rm test*file' will delete test1file, test12file, testBLABLABLAfile. It will also delete any other filename that begins with 'test-' and ends in '-file', including testfile.
It is obvious that we must be extremely careful when combining deletion commands with wildcards. 'rm *' will delete every file in the current directory, and it won't use Trash.
Extra information about Linux commands
We can learn more about any of the Linux commands with [command] --help and man [command].
[command] --help will show the usage of the command, and the available options and switches.
man [command] will show the command's manual, which is an extended version of the --help output.
However, not all Linux commands have a manual or a --help option.
Basic Linux commands for the terminal
In this list, we haven't included every possible command, just the Linux commands that would be more useful to a Linux beginner. In the future, we will create a separate guide with advanced Linux commands.
Basic navigation
These Linux commands will help us navigate to particular directories and search for files.
Directory access shortcuts
When we want to navigate to a particular directory or access a specific file, it's handy to keep in mind the following shortcuts.
What to do with commands that return too many results
If we run 'ls' on a directory with 1,000 files, or we use 'locate *.png' on a disk with lots of png pictures, we will get too many results.
In this case, we can use a pipe with the vertical bar '|' symbol (accessible with 'Shift + ' ) and more or less.
With locate *.png | more we will get the results page by page, and we can reveal the next pages by pressing space. We quit by pressing 'q'.
With locate *.png | less we will still get the first page of results, but navigate up and down with the arrow keys. Again, we quit with 'q'.
File and Directory Handling
This is how to create, delete, and search for files and directories.
File content
Creating and deleting files and directories is fine. But what if we want to access the file content at the Linux Terminal?
Are you looking for other Linux commands?
If you want to know more about one of the Linux commands we mentioned or are curious about another Linux command, leave us a comment.
Support PCsteps
Do you want to support PCsteps, so we can post high quality articles throughout the week?
You can like our Facebook page, share this post with your friends, and select our affiliate links for your purchases on Amazon.com or Newegg.
If you prefer your purchases from China, we are affiliated with the largest international e-shops:
On this page
There are a countless number of commands in Linux. We are bound to use a number of them on a daily routine or numerous times to perform common tasks than others. It is important to note that certain commands are “distro-based” – they can only be found in specific distros. While others are generic Unix/Linux commands that you’ll find in all if not most mainstream distros.
In this article, we will introduce you a list of most frequently used Linux commands with their examples for easy learning. You can find the actual description of each Linux command in their manual page which you can access like this:
adduser/addgroup Command
The adduser and addgroup commands are used to add a user and group to the system respectively according to the default configuration specified in /etc/adduser.conf file.
For more adduser and addgroup commands: 15 Practical Examples on adduser Command in Linux
agetty Command
agetty is a program which manages physical or virtual terminals and is invoked by init. Once it detects a connection, it opens a tty port, asks for a user’s login name and calls up the /bin/login command. Agetty is a substitute of Linux getty:
alias Command
alias is a useful shell built-in command for creating aliases (shortcut) to a Linux command on a system. It is helpful for creating new/custom commands from existing Shell/Linux commands (including options):
The above command will create an alias called home for /home/tecmint/public_html directory, so whenever you type home in the terminal prompt, it will put you in the /home/tecmint/public_html directory.
anacron Command
anacron is a Linux facility used to run commands periodically with a frequency defined in days, weeks and months.
Unlike its sister cron; it assumes that a system will not run continuously, therefore if a scheduled job is due when the system is off, it’s run once the machine is powered on.
For more information about anacron and cron read: Cron Vs Anacron: How to Schedule Jobs Using Anacron on Linux
apropos Command
apropos command is used to search and display a short man page description of a command/program as follows.
apt Command
apt tool is a relatively new higher-level package manager for Debian/Ubuntu systems:
For more apt usage read: 15 Useful Examples on APT Command
apt-get Command
apt-get is a powerful and free front-end package manager for Debian/Ubuntu systems. It is used to install new software packages, remove available software packages, upgrade existing software packages as well as upgrade entire operating system.
For more apt-get usage, read: 25 Useful Commands of APT-GET for Package Management
aptitude Command
aptitude is a powerful text-based interface to the Debian GNU/Linux package management system. Like apt-get and apt; it can be used to install, remove or upgrade software packages on a system.
For more usage on aptitude, read: Learn Debian Package Management with Aptitude Command
arch Command
arch is a simple command for displaying machine architecture or hardware name (similar to uname -m):
arp Command
ARP (Address Resolution Protocol) is a protocol that maps IP network addresses of a network neighbor with the hardware (MAC) addresses in an IPv4 network.
You can use it as below to find all alive hosts on a network:
at Command
at command is used to schedule tasks to run in a future time. It’s an alternative to cron and anacron, however, it runs a task once at a given future time without editing any config files:
For example, to shutdown the system at 23:55 today, run:
atq Command
atq command is used to view jobs in at command queue:
atrm Command
atrm command is used to remove/deletes jobs (identified by their job number) from at command queue:
For more usage about at command, read: How to Use ‘at’ Command to Schedule a Task in Linux
awk Command
Awk is a powerful programming language created for text processing and generally used as a data extraction and reporting tool.
For more Awk concepts (basic and advance) with simple and easy-to-understand, we’ve created a book that contains 13 chapters with a total of 41 pages, which covers all Awk basic and advance usage with practical examples: Awk Getting Started Guide for Beginners
batch Command
batch is also used to schedule tasks to run a future time, similar to the at command.
basename Command
basename command helps to print the name of a file stripping of directories in the absolute path:
bc Command
bc is a simple yet powerful and arbitrary precision CLI calculator language which can be used like this:
bg Command
bg is a command used to send a process to the background.
To learn more about bg command, read: Start Linux Command in Background and Detach Process in Terminal
bzip2 Command
bzip2 command is used to compress or decompress file(s).
To learn more examples on bzip2, read: How to Compress and Decompress a .bz2 File in Linux
cal Command
The cal command print a calendar on the standard output.
cat Command
cat command is used to view contents of a file or concatenate files, or data provided on standard input, and display it on the standard output.
To learn more about cat command, read: 13 Useful Cat Command Examples on Linux
chgrp Command
chgrp command is used to change the group ownership of a file. Provide the new group name as its first argument and the name of file as the second argument like this:
chmod Command
chmod command is used to change/update file access permissions like this.
chown CommandLinux Command Cheat Sheet Pdf
chown command changes/updates the user and group ownership of a file/directory like this.
To learn more about chgrp, chmod and chwon commands, read: Managing Users & Groups, File Permissions & Attributes in Linux
cksum Command
cksum command is used to display the CRC checksum and byte count of an input file.
clear Command
clear command lets you clear the terminal screen, simply type.
cmp Command
cmp performs a byte-by-byte comparison of two files like this.
comm Command
comm command is used to compare two sorted files line-by-line as shown below.
cp CommandAdvance Linux Commands
cp command is used for copying files and directories from one location to another.
For more information on how to copy files in Linux, read:
date Command
date command displays/sets the system date and time like this.
To learn more about how to set date in Linux, read: How to Set System Date in Linux
dd Command
dd command is used for copying files, converting and formatting according to flags provided on the command line. It can strip headers, extracting parts of binary files and so on.
The example below shows creating a boot-able USB device:
df Command
df command is used to show file system disk space usage as follows.
For more usage on df command, read: 12 Useful ‘df’ Command Examples to Check Disk Space
diff Command
diff command is used to compare two files line by line. It can also be used to find the difference between two directories in Linux like this:
Some useful diff tools for Linux: 8 Best File Comparison and Difference (Diff) Tools for Linux
dir Command
dir command works like Linux ls command, it lists the contents of a directory.
dmidecode Command
dmidecode command is a tool for retrieving hardware information of any Linux system. It dumps a computer’s DMI (a.k.a SMBIOS) table contents in a human-readable format for easy retrieval.
To view your system hardware info, you can type:
Some useful tools to find out Linux system hardware info: 10 Useful Commands to Get Linux Hardware Information
du Command
du command is used to show disk space usage of files present in a directory as well as its sub-directories as follows.
echo Command
echo command prints a text of line provided to it.
eject Command
eject command is used to eject removable media such as DVD/CD ROM or floppy disk from the system.
env Command
env command lists all the current environment variables and used to set them as well.
Learn more on How to Set and Unset Environment Variables in Linux
exit Command
exit command is used to exit a shell like so.
expr Command
expr command is used to calculate an expression as shown below.
factor Command
factor command is used to show the prime factors of a number.
find Command
find command lets you search for files in a directory as well as its sub-directories. It searches for files by attributes such as permissions, users, groups, file type, date, size and other possible criteria.
Learn more on how to find files in Linux:
free Command
free command shows the system memory usage (free, used, swapped, cached, etc.) in the system including swap space. Use the
-h option to display output in human friendly format.
Learn more on how to find memory usage in Linux.
grep Command
grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern as follows.
Learn more about grep command usage in Linux.
groups Command
groups command displays all the names of groups a user is a part of like this.
gzip Command
Gzip helps to compress a file, replaces it with one having a
.gz extension as shown below:
gunzip Command
gunzip expands or restores files compressed with gzip command like this.
head Command
head command is used to show first lines (10 lines by default) of the specified file or stdin to the screen:
history Command
history command is used to show previously used commands or to get info about command executed by a user.
Learn more about Linux history command.
hostname Command
hostname command is used to print or set system hostname in Linux.
hostnamectl Command
hostnamectl command controls the system hostname under systemd. It is used to print or modify the system hostname and any related settings:
Fallout new vegas revolver build. In Honest Hearts, the Courier takes part in a trading expedition to Utah's, when they are attacked by tribal raiders. While trying to return to the Mojave, the Courier becomes involved in conflicts between the tribes and between a 'New Canaanite' (post-apocalyptic incarnation of ) missionary and an individual known as the 'Burned Man', Caesar's former Legate, who, after losing the first battle of Hoover Dam, was covered in, set on fire, and thrown into the.
hwclock
hwclock is a tool for managing the system hardware clock; read or set the hardware clock (RTC).
hwinfo Command
hwinfo is used to probe for the hardware present in a Linux system like this.
Learn more about how to get Linux hardware info.
id Command
id command shows user and group information for the current user or specified username as shown below.
ifconfig Command
ifconfig command is used to configure a Linux systems network interfaces. It is used to configure, view and control network interfaces.
ionice Command
ionice command is used to set or view process I/O scheduling class and priority of the specified process.
If invoked without any options, it will query the current I/O scheduling class and priority for that process:
To understand how it works, read this article: How to Delete HUGE (100-200GB) Files in Linux
iostat Command
iostat is used to show CPU and input/output statistics for devices and partitions. It produces useful reports for updating system configurations to help balance the input/output load between physical disks.
ip Command
ip command is used to display or manage routing, devices, policy routing and tunnels. It also works as a replacement for well known ifconfig command.
This command will assign an IP address to a specific interface (eth1 in this case).
iptables Command
iptables is a terminal based firewall for managing incoming and outgoing traffic via a set of configurable table rules.
The command below is used to check existing rules on a system (using it may require root privileges).
Learn more about iptables firewall in Linux.
iw Command
iw command is used to manage wireless devices and their configuration.
iwlist Command
iwlist command displays detailed wireless information from a wireless interface. The command below enables you to get detailed information about the wlp1s0 interface.
kill Command
kill command is used to kill a process using its PID by sending a signal to it (default signal for kill is TERM).
killall Command
killall command is used to kill a process by its name.
Learn more about kill and killall command in Linux.
kmod Command
kmod command is used to manage Linux kernel modules. To list all currently loaded modules, type.
last Command
last command display a listing of last logged in users.
ln Command
ln command is used to create a soft link between files using the
-s flag like this.
locate Command
locate command is used to find a file by name. The locate utility works better and faster than it’s find counterpart.
The command below will search for a file by its exact name (not *name*):
login Command
login command is used to create a new session with the system. You’ll be asked to provide a username and a password to login as below.
ls Command
ls command is used to list contents of a directory. It works more or less like dir command.
The
-l option enables long listing format like this.
To know more about ls command, read our guides.
lshw Command
lshw command is a minimal tool to get detailed information on the hardware configuration of the machine, invoke it with superuser privileges to get a comprehensive information.
lscpu Command
lscpu command displays system’s CPU architecture information (such as number of CPUs, threads, cores, sockets, and more).
lsof Command
lsof command displays information related to files opened by processes. Files can be of any type, including regular files, directories, block special files, character special files, executing text reference, libraries, and stream/network files.
To view files opened by a specific user’s processes, type the command below.
lsusb Command
lsusb command shows information about USB buses in the system and the devices connected to them like this.
man Command
man command is used to view the on-line reference manual pages for commands/programs like so.
md5sum Command
md5sum command is used to compute and print the MD5 message digest of a file. If run without arguments, debsums checks every file on your system against the stock md5sum files:
mkdir Command
mkdir command is used to create single or more directories, if they do not already exist (this can be overridden with the
-p option).
more Command
more command enables you to view through relatively lengthy text files one screenful at a time.
Check difference between more and less command and Learn Why ‘less’ is Faster Than ‘more’ Command
mv Command
mv command is used to rename files or directories. It also moves a file or directory to another location in the directory structure.
nano Command
nano is a popular small, free and friendly text editor for Linux; a clone of Pico, the default editor included in the non-free Pine package.
To open a file using nano, type:
nc/netcat Command
nc (or netcat) is used for performing any operation relating to TCP, UDP, or UNIX-domain sockets. It can handle both IPv4 and IPv6 for opening TCP connections, sending UDP packets, listening on arbitrary TCP and UDP ports, performing port scanning.
The command below will help us see if the port 22 is open on the host 192.168.56.5.
Learn more examples and usage on nc command.
netstat Command
netstat command displays useful information concerning the Linux networking subsystem (network connections, routing tables, interface statistics, masquerade connections, and multicast memberships).
This command will display all open ports on the local system:
nice Command
nice command is used to show or change the nice value of a running program. It runs specified command with an adjusted niceness. When run without any command specified, it prints the current niceness.
The following command starts the process “tar command” setting the “nice” value to 12.
nmap Command
nmap is a popular and powerful open source tool for network scanning and security auditing. It was intended to quickly scan large networks, but it also works fine against single hosts.
The command below will probe open ports on all live hosts on the specified network.
nproc Command
nproc command shows the number of processing units present to the current process. It’s output may be less than the number of online processors on a system.
openssl Command
The openssl is a command line tool for using the different cryptography operations of OpenSSL’s crypto library from the shell. The command below will create an archive of all files in the current directory and encrypt the contents of the archive file:
passwd Command
passwd command is used to create/update passwords for user accounts, it can also change the account or associated password validity period. Note that normal system users may only change the password of their own account, while root may modify the password for any account.
pidof Command
pidof displays the process ID of a running program/command.
ping Command
ping command is used to determine connectivity between hosts on a network (or the Internet):
ps Command
ps shows useful information about active processes running on a system. The example below shows the top running processes by highest memory and CPU usage.
pstree Command
pstree displays running processes as a tree which is rooted at either PID or init if PID is omitted.
pwd Command
pwd command displays the name of current/working directory as below.
rdiff-backup Command
rdiff-backup is a powerful local/remote incremental backup script written in Python. It works on any POSIX operating system such as Linux, Mac OS X.
Note that for remote backups, you must install the same version of rdiff-backup on both the local and remote machines. Below is an example of a local backup command:
reboot Command
reboot command may be used to halt, power-off or reboot a system as follows.
rename Command
rename command is used to rename many files at once. If you’ve a collection of files with “.html” extension and you want to rename all of them with “.php” extension, you can type the command below.
rm command
rm command is used to remove files or directories as shown below.
rmdir Command
rmdir command helps to delete/remove empty directories as follows.
scp Command
scp command enables you to securely copy files between hosts on a network, for example.
shutdown Command
shutdown command schedules a time for the system to be powered down. It may be used to halt, power-off or reboot the machine like this.
Learn how to show a Custom Message to Users Before Linux Server Shutdown.
sleep Command
sleep command is used to delay or pause (specifically execution of a command) for a specified amount of time.
sort Command
sort command is used to sort lines of text in the specified file(s) or from stdin as shown below
Learn more examples of sort command in Linux.
split Command
split as the name suggests, is used to split a large file into small parts.
ssh Command
ssh (SSH client) is an application for remotely accessing and running commands on a remote machine. It is designed to offer a secure encrypted communications between two untrusted hosts over an insecure network such as the Internet.
Learn more about ssh command and how to use it on Linux.
stat Command
stat is used to show a file or file system status like this (
-f is used to specify a filesystem).
su Command
su command is used to switch to another user ID or become root during a login session. Note that when su is invoked without a username, it defaults to becoming root.
sudo Command
sudo command allows a permitted system user to run a command as root or another user, as defined by the security policy such as sudoers.
In this case, the real (not effective) user ID of the user running sudo is used to determine the user name with which to query the security policy.
Learn more about sudo command and how to use it on Linux.
sum Command
sum command is used to show the checksum and block counts for each each specified file on the command line.
tac Command
tac command concatenates and displays files in reverse. It simply prints each file to standard output, showing last line first.
tail Command
tail command is used to display the last lines (10 lines by default) of each file to standard output.
If there more than one file, precede each with a header giving the file name. Use it as follow (specify more lines to display using
-n option).
talk Command
talk command is used to talk to another system/network user. To talk to a user on the same machine, use their login name, however, to talk to a user on another machine use ‘[email protected]’.
tar Command
tar command is a most powerful utility for archiving files in Linux.
Learn more about tar command and its usage on Linux.
tee Command
tee command is used to read from standard input and prints to standard output and files as shown below.
time Command
time command runs programs and summarizes system resource usage.
top Command
top program displays all processes on a Linux system in regards to memory and CPU usage and provides a dynamic real-time view of a running system.
touch Command
touch command changes file timestamps, it can also be used to create a file as follows.
tr Command
tr command is a useful utility used to translate (change) or delete characters from stdin, and write the result to stdout or send to a file as follows.
uname Command
uname command displays system information such as operating system, network node hostname kernel name, version and release etc.
Use the
-a option to show all the system information:
uniq Command
uniq command displays or omits repeated lines from input (or standard input). To indicate the number of occurrences of a line, use the
-c option.
uptime Command
uptime command shows how long the system has been running, number of logged on users and the system load averages as follows.
users Command
users command shows the user names of users currently logged in to the current host like this.
vim/vi Command
vim (Vi Improved) popular text editor on Unix-like operating systems. It can be used to edit all kinds of plain text and program files.
Learn how to use vi/vim editor in Linux along with some tips and tricks.
w Command
w command displays system uptime, load averages and information about the users currently on the machine, and what they are doing (their processes) like this.
wall Command
wall command is used to send/display a message to all users on the system as follows.
watch Command
watch command runs a program repeatedly while displaying its output on fullscreen. It can also be used to watch changes to a file/directory. The example below shows how to watch the contents of a directory change.
wc Command
wc command is used to display newline, word, and byte counts for each file specified, and a total for many files.
wget Command
wget command is a simple utility used to download files from the Web in a non-interactive (can work in the background) way.
whatis Command
whatis command searches and shows a short or one-line manual page descriptions of the provided command name(s) as follows.
which Command
which command displays the absolute path (pathnames) of the files (or possibly links) which would be executed in the current environment.
who Command
who command shows information about users who are currently logged in like this.
whereis Command
whereis command helps us locate the binary, source and manual files for commands.
xargs Command
xargs command is a useful utility for reading items from the standard input, delimited by blanks (protected with double or single quotes or a backslash) or newlines, and executes the entered command.
The example below show xargs being used to copy a file to multiple directories in Linux.
yes Command
yes command is used to display a string repeatedly until when terminated or killed using [
Ctrl + C ] as follows.
youtube-dl Command
youtube-dl is a lightweight command-line program to download videos and also extract MP3 tracks from YouTube.com and a few more sites.
The command below will list available formats for the video in the provided link.
zcmp/zdiff Command
zcmp and zdiff minimal utilities used to compare compressed files as shown in the examples below.
zip Command
zip is a simple and easy-to-use utility used to package and compress (archive) files.
zz Command
zz command is an alias of the fasd commandline tool that offers quick access to files and directories in Linux. It is used to quickly and interactively cd into a previously accessed directory by selecting the directory number from the first field as follows.
That’s it for now! As we mentioned before, there are a countless number of commands in Linux. The list is possibly longer than we can offer. Use the feedback form below to share any useful and frequently used commands missing in this list.
Share
Before learning the tools of a CentOS Linux Administrator, it is important to note the philosophy behind the Linux administration command line.
Linux was designed based on the Unix philosophy of “small, precise tools chained together simplifying larger tasks”. Linux, at its root, does not have large single-purpose applications for one specific use a lot of the time. Instead, there are hundreds of basic utilities that when combined offer great power to accomplish big tasks with efficiency.
Examples of the Linux Philosophy
For example, if an administrator wants a listing of all the current users on a system, the following chained commands can be used to get a list of all system users. On execution of the command, the users are on the system are listed in an alphabetical order.
It is easy to export this list into a text file using the following command.
It is also possible to compare the user list with an export at a later date.
With this approach of small tools chained to accomplish bigger tasks, it is simpler to make a script performing these commands, than automatically email results at regular time intervals.
Basic Commands every Linux Administrator should be proficient in are −
In the Linux world, Administrators use filtering commands every day to parse logs, filter command output, and perform actions with interactive shell scripts. As mentioned, the power of these commands come in their ability to modify one another through a process called piping.
The following command shows how many words begin with the letter a from the CentOS main user dictionary.
Related articles:
Load more
Open-source Linux is a popular alternative to Microsoft Windows, and if you choose to use this low-cost or free operating system, you need to know some basic Linux commands to configure, operate, and interact with your system smoothly.
When dealing with the Linux operating system, commands are required as inputs to inform or direct a computer program to perform a specific operation. Understanding the most basic Linux commands will allow you to successfully navigate directories, manipulate files, change permissions, display information such as disk space, and more. Obtaining basic knowledge of the most common commands will help you easily execute tasks via the command line.
Find the most common Linux commands in this table:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |