CHEATSHEET: Linux Core Utility Commands
published on Thu Apr 02 2020Simple Commands
date- displays the current time and datecal- displays a calendar of the current monthdf- displays the current amount of free space on our disk drivesfree- displays the amount of free memoryclear- clear the terminal screenhistory- display or manipulate the history listexit- ends a terminal session
Navigation Commands
pwd- display the current working directorycd- change current working directory to another specified directory
Linux Path names
Linux path names can be specified in the following two ways:
- absolute path names - specify the path name from the root (
/) directory - relative path names - specify the path name from the current directory using dot notation
.- refers to the current directory..- refers to the parent directory of the current directory~- refers to the current user’s home directory
Filesystem commands
file- determine file typeless- view contents of a filels- list files and directories in a specific directory
ls common arguments
-a- lists all files-h- display file sizes in human-readable format-l- display long format results-s- sort by file size, largest first-t- sort by modified time, newest first
Manipulating Files and Directories
cp- copy files and directoriesmv- move/rename files and directoriesmkdir- create directoriesrm- remove files and directoriesln- create hard and symbolic linksalias- create an alias for a command. Useunaliasto remove an aliased commandtouch- create a new filetar- used to bundle, compress and uncompress files and folders
cp, mv & rm common arguments
-a- copy the files and directories and all of their attributes-i- before overwriting an existing file, prompt the user for confirmation-r- recursively copy directories and their contents-u- when copying, only copy files that don’t exist or are newer than the existing corresponding files in the destination directory-v- display informative messages as the copy is performed
Getting help
type- indicate how a command name is interpretedwhich- display which executable program will be executedhelp- get help for shell builtinsman- display a command’s manual pageapropos- display a list of appropriate commandsinfo- display a command’s info entrywhatis- display one-line manual page descriptions
Parsing Text
echo- display a line of textcat- concatenate files to the standard outputsort- sort lines of textuniq- report or omit repeated linesgrep- print lines matching a patternwc- print newline, word and byte counts for each filehead- output the first part of a filetail- output the last part of a file
Permissions
id- display user identitychmod- change a file’s modeumask- set the default file permissionssu- run a shell as another usersudo- execute a command as another userchown- change a file’s ownerchgrp- change a file’s group ownershippasswd- change a user’s password
Processes
ps- report a snapshot of current processestop- display tasksjobs- list active jobsbg- place a job in the backgroundfg- place a job in the foregroundkill- send a kill signal to a processkillall- kill processes by nameshutdown- shut down or reboot the system