When coming up to speed as a Linux user, it helps to have a cheat sheet that can help introduce you to some of the more useful commands.\nIn the 18 tables below, you\u2019ll find sets of commands with simple explanations and usage examples that might help you or Linux users you support become more productive on the command line.\n\nGetting familiar with your account\nThese commands will help new Linux users become familiar with their Linux accounts.\n\n\n\nCommand\nFunction\nExample\n\n\npwd\nDisplays your current location in the file system\npwd\n\n\nwhoami\nDisplays your username\u00a0\u2013 most useful if you switch users with su and need to be reminded what account you're using currently\nwhoami\n\n\nls\nProvides a file listing. With -a, it also displays files with names starting with a period (e.g., .bashrc). With -l, it also displays file permissions, sizes and last updated date\/time.\nlsls -als -l\n\n\nenv\nDisplays your user environment settings (e.g., search path, history size, home directory, etc.)\nenv\n\n\necho\nRepeats the text you provide or displays the value of some variable\necho helloecho $PATH\n\n\nhistory\nLists previously issued commands\nhistoryhistory | tail -5\n\n\npasswd\nChanges your password. Note that complexity requirements may be enforced.\npasswdhistory | tail -5\n\n\n\nSee more commands below this ad.\nExamining files\nLinux provides several commands for looking at the content and nature of files. These are some of the most useful commands.\n\n\n\nCommand\nFunction\nExample\n\n\ncat\nDisplays the entire contents of a text file.\ncat .bashrc\n\n\nmore\nDisplays the contents of a text file one screenful at a time. Hit the spacebar to move to each additional chunk.\nmore .bash_history\n\n\nless\nDisplays the contents of a text file one screenful at a time, but in a manner that allows you to back up using the up arrow key.\nless .bash_history\n\n\nfile\nIdentifies files by type (e.g., ASCII text, executable, image, directory)\nfile myfilefile ~\/.bashrcfile \/bin\/echo\n\n\n\n\u00a0\nManaging files\nThese are some Linux commands for changing file attributes as well as renaming, moving and removing files.\n\n\n\nCommand\nFunction\nExample\n\n\nchmod\nChanges file permissions (who can read it, whether it can be executed, etc.)\nchmod a+x myscriptchmod 755 myscript\n\n\nchown\nChanges file owner\nsudo chown jdoe myfile\n\n\ncp\nMakes a copy of a file.\ncp origfile copyfile\n\n\nmv\nMoves or renames a file\u00a0\u2013 or does both\nmv oldname newnamemv file \/new\/locationmv file \/newloc\/newname\n\n\nrm\nDeletes a file or group of files\nrm filerm *.jpgrm -r directory\n\n\n\n\u00a0\nCreating and editing files\nLinux systems provide commands for creating files and directories. Users can choose the text editor they are comfortable using. Some require quite a bit of familiarity before they'll be easy to use while others are fairly self-explanatory.\n\n\n\nCommand\nFunction\nExample\n\n\nnano\nAn easy-to-use text editor that requires you to move around in the file using your arrow keys and provides control sequences to locate text, save your changes, etc.\nnano myfile\n\n\nvi\nA more sophisticated editor that allows you to enter commands to find and change text, make global changes, etc.\nvi myfile\n\n\nex\nA text editor designed for programmers and has both a line-oriented and visual mode\nex myfile\n\n\ntouch\nCreates a file if it doesn't exist or updates its timestamp if it does\ntouch newfiletouch updatedfile\n\n\n>\nCreates files by directing output to them. A single > creates a file while >> appends to an existing file.\ncal > calendarps > myprocsdate >> date.log\n\n\nmkdir\nCreates a directory\nmkdir mydirmkdir ~\/mydirmkdir \/tmp\/backup\n\n\n\n\u00a0\nMoving around the file system\nThe command for moving around the Linux file system is ls, but there are many variations.\n\n\n\nCommand\nFunction\nExample\n\n\ncd\nWith no arguments, takes you to your home directory. The same thing would happen if you typed cd $HOME or cd ~\ncd\n\n\ncd ..\nMoves up (toward \/) one directory from your current location\ncd ..\n\n\ncd \nTakes you to the specified location. If the location begins with a \/, it is taken to be relative to the root directory; otherwise it is taken as being relative to your current location. The ~ character represents your home directory.\ncd \/tmpcd Documentscd ~\/Documents\n\n\n\n\u00a0\nLearning about and identifying commands\nThere are a number of Linux commands that can help you learn about other commands, the options they offer and where these commands are are located in the file system. Linux systems also provide a command that can help you to learn what commands are available related to some subject\u00a0\u2013 for example, commands that deal with user accounts.\n\n\n\nCommand\nFunction\nExample\n\n\nman\nDisplays the manual (help) page for a specified command and (with -k) provides a list of commands related to a specified keyword\nman cdman -k account\n\n\nwhich\nDisplays the location of the executable that represents the particular command\nwhich cd\n\n\napropos\nLists commands associated with a particular topic or keyword\napropos userapropos account\n\n\n\n\u00a0\nFinding files\nThere are two commands that can help you find files on Linux, but they work very differently. One searches the file system while the other looks through a previously built database.\n\n\n\nCommand\nFunction\nExample\n\n\nfind\nLocates files based on criteria provided (file name, type, owner, permissions, size, etc.). Unless provided with a location from which to start the search, find only looks in the current directory.\nfind . -name myfilefind \/tmp -type d\n\n\nlocate\nLocates files using the contents of the \/var\/lib\/mlocate\/mlocate.db which is updated by the updatedb command usually run through cron. No starting location is required.\nlocate somefilelocate "*.html" -n 20\n\n\n\n\u00a0\nViewing running processes\nYou can easily view processes that are running on the system\u00a0\u2013 yours, another user's or all of them.\n\n\n\nCommand\nFunction\nExample\n\n\nps\nShows processes that you are running in your current login session\nps\n\n\nps -ef\nShows all processes that are currently running on the system\nps -efps -ef | more\n\n\npstree\nShows running processes in a hierarchical (tree-like) display that demonstrates the relationships between processes (-h highlights current process)\npstreepstree usernamepstree -h\n\n\n\n\u00a0\nStarting, stopping and listing services\nThese commands allow you to display services as well as start and stop them.\n\n\n\nCommand\nFunction\nExample\n\n\nsystemctl\nThe systemctl command can start, stop, restart and reload services. Privileged access is required.\nsudo systemctl stop apache2.servicesudo systemctl restart apache2.servicesudo systemctl reload apache2.service\n\n\nservice\nLists services and indicates whether they are running\nservice --status-all\n\n\n\n\u00a0\nKilling processes\nLinux offers a few commands for terminating processes. Privileged access is needed if you did not start the process in question.\n\n\n\nCommand\nFunction\nExample\n\n\nkill\nTerminates a running process provided you have the authority to do so\nkill 8765sudo kill 1234kill -9 3456\n\n\nkillall\nTerminates all processes with the provided name\nkillall badproc\n\n\npkill\nTerminates a process based on its name\npkill myproc\n\n\n\n\u00a0\nIdentifying your OS release\nThe table below lists commands that will display details about the Linux OS that is running on a system.\n\n\n\nCommand\nFunction\nExample\n\n\nuname\nDisplays information on OS release in a single line of text\nuname -auname -r\n\n\nlsb_release\nOn Debian-based systems, this command displays information on the OS release including its codename and distributor ID\nlsb_release -a\n\n\nhostnamectl\nDisplays information on the system including hostname, chassis type, OS, kernel and architecture\nhostnamectl\n\n\n\n\u00a0\nGauging system performance\nThese are some of the more useful tools for examining system performance.\n\n\n\nCommand\nFunction\nExample\n\n\ntop\nShows running processes along with resource utilization and system performance data. Can show processes for one selected user or all users. Processes can be ordered by various criteria (CPU usage by default)\ntoptop jdoe\n\n\natop\nSimilar to top command but more oriented toward system performance than individual processes\natop\n\n\nfree\nShows memory and swap usage\u00a0\u2013 total, used and free\nfree\n\n\ndf\nDisplay file system disk space usage\ndfdf -h\n\n\n\n\u00a0\nManaging users and groups\nCommands for creating and removing user accounts and groups are fairly straightforward.\n\n\n\nCommand\nFunction\nExample\n\n\nuseradd\nAdds a new user account to the system. A username is mandatory. Other fields (user description, shell, initial password, etc.) can be specified. Home directory will default to \/home\/username.\nuseradd -c "John Doe" jdoeuseradd -c "Jane Doe" -g admin -s \/bin\/bash jbdoe\n\n\nuserdel\nRemoves a user account from the system. The -f option runs a more forceful removal, deleting the home and other user files even if the user is still logged in.\nuserdel jbdoeuserdel -f jbdoe\n\n\ngroupadd\nAdds a new user group to the system, updating the \/etc\/group.\ngroupadd developers\n\n\ngroupdel\nRemoves a user group from the system\ngroupdel developers\n\n\n\n\u00a0\nExamining network connections\nThe commands below help you view network interfaces and connections.\n\n\n\nCommand\nFunction\nExample\n\n\nip\nDisplays information on network interfaces\nip a\n\n\nss\nDisplays information on sockets. The -s option provides summary stats. The -l option shows listening sockets. The -4 or -6\u00a0options restrict output to IPv4 or IPv6 connections.\nss -sss -lss -4 state listening\n\n\nping\nCheck connectivity to another system\nping remhostping 192.168.0.11\n\n\n\n\u00a0\nManaging security\nThere are many aspects to managing security on a Linux system, but there are also a lot of commands that can help. The commands below are some that will get you started. Click on this link to see these and other commands on 22 essential Linux security commands.\n\n\n\nCommand\nFunction\nExample\n\n\nvisudo\nThe visudo command allows you to configure privileges that will allow select individuals to run certain commands with superuser authority. The command does this by making changes to the \/etc\/sudoers file.\nvisudo\n\n\nsudo\nThe sudo command is used by privileged users (as defined in the \/etc\/sudoers file to run commands as root.\nsudo useradd jdoe\n\n\nsu\nSwitches to another account. This requires that you know the user's password or can use sudo and provide your own password. Using the - means that you also pick up the user's environment settings.\nsu (switch to root)su - jdoesudo su - jdoe\n\n\nwho\nShows who is logged into the system\nwho\n\n\nlast\nLists last logins for specified user using records from the \/var\/log\/wtmp file.\nlast jdoe\n\n\nufw\nManages the firewall on Debian-based systems.\nsudo ufw statussudo ufs allow sshufw show\n\n\nfirewall-cmd\nManages the firewall (firewalld) on RHEL and related systems.\nfirewall-cmd --list-servicesfirewall-cmd --get-zones\n\n\niptables\nDisplays firewall rules.\nsudo iptables -vL -t security\n\n\n\n\u00a0\nSetting up and running scheduled processes\nTasks can be scheduled to run periodically using the command listed below.\n\n\n\nCommand\nFunction\nExample\n\n\ncrontab\nSets up and manages scheduled processes. With the -l option, cron jobs are listed. With the -e option, cron jobs can be set up to run at selected intervals.\ncrontab -lcrontab -l -u usernamecrontab -e\n\n\nanacron\nAllows you to run scheduled jobs on a daily basis only. If the system is powered off when a job is supposed to run, it will run when the system boots.\nsudo vi \/etc\/anacrontab\n\n\n\n\u00a0\nUpdating, installing and listing applications\nThe commands for installing and updating applications depend on what version of Linux you are using, specifically whether it's Debian- or RPM-based.\n\n\n\nCommand\nFunction\nExample\n\n\napt update\nOn Debian-based systems, updates the list of available packages and their versions, but does not install or upgrade any packages\nsudo apt update\n\n\napt upgrade\nOn Debian-based systems, installs newer versions of installed packages\nsudo apt upgrade\n\n\napt list\nLists all packages installed on Debian-based system. With --upgradable option, it shows only those packages for which upgrades are available.\napt listapt list --installedapt list --upgradable\n\n\napt install\nOn Debian-based systems, installs requested package\nsudo apt install apache2\n\n\nyum update\nOn RPM-cased systems, updates all or specified packages\nsudo yum updateyum update mysql\n\n\nyum list\nOn RPM-based systems, lists package\nsudo yum update mysql\n\n\nyum install\nOn RPM-based systems, installs requested package\nsudo yum -y install firefox\n\n\nyum list\nOn RPM-based systems, lists known and installed packages\nsudo yum listsudo yum list --installed\n\n\n\n\u00a0\nShutting down and rebooting\nCommands for shutting down and rebooting Linux systems require privileged access. Options such as +15 refer to the number of minutes that the command will wait before doing the requested shutdown.\n\n\n\nCommand\nFunction\nExample\n\n\nshutdown\nShuts down the system at the requested time. The -H option halts the system while the -P powers it down as well.\nsudo shutdown -H nowshutdown -H +15shutdown -P +5\n\n\nhalt\nShuts down the system at the requested time.\nsudo haltsudo halt -psudo halt --reboot\n\n\npoweroff\nPowers down the system at the requested time.\nsudo shutdown -H nowsudo shutdown -H +15sudo shutdown -P +5\n\n\n\n\u00a0\nWait, wait, there's more!\nRemember to consult the man pages for more details on these commands. A cheat sheet provides only a quick explanation and a handful of command examples to help you get started.