Show Menu
Cheatography

Linux System Administration Cheat Sheet by

Various commands, directories, tips and tricks for Linux sys admin'ing

Network Commands

Command
Descri­ption
Parame­ter­/Usage
wget
Downloads something from a web address
ssh
Remote login or command run
"ssh userna­me@­ser­ver­"
scp, sftp
Remote file copy
openssl
For generating stuff for encryption
ssh-keygen
For generating public­/pr­ivate key pairs
dnf
Package manager for Fedora. Use it to download, update, and install all sorts of software
ifconfig
Use without parameters to get general info on network connec­tions. Also used for assigning IP addresses and setting up networking config stuff for interface devices
netmask
Used for setting network submask
route
For adding entries to a routing table
netstat
For displaying network info
ip
For Internet Protocol activities
traceroute
Given an address, will identify all of the places your packets travel to to get to that address
ping
Sends packets to an IP, seeing how long it takes to get a response
dig
Queries DNS servers to get info on a domain

System & Disk Commands

Command
Descri­ption
Parameters
du
Disk usage; shows disk usage of files in directory
h: human readable. a: all files, not just direct­ories
free
Shows amount of free & and used memory in system
df
Report on file system & disk space usage
lsblk
Report info about block devices
fdisk
Manipulate disk partioning
l: list disks
Uname
Print system inform­ation
export
For setting an enviro­nment variable
unmount
Unmounts the specified disk
eject
Ejects the specified disk

Common Commands

Name
Descri­ption
Parame­ter­s/Notes
ls
list everything in given directory (default is present dir)
l: long, more detailed view. a: show all, even hidden files/­dir­ect­ories
cd
navigate to another directory
pwd
Present Working Directory; shows current directory
cp
Copy a file from one place to another
rm
Remove a file or directory
f: force remove, ignoring warnin­gs/­any­thing. r: recursive; use this to delete direct­ories
mv
Moves a file
Can be used to rename files, by 'moving' a file to the same directory, with a different name
rmdir
Removes a directory
mkdir
Creates a directory
-p to make parents; can build a chain of non-ex­istent direct­ories all at once
touch
Updates a file's last-e­dited date.
Can be used to create files- it will create a file if the given file does not exist
history
lists history of previous commands
man
Lists manual page for a given command, that'll tell you alllll about what a command can do and how to use it
reboot
Reboots the machine
 

Direct­ories

Directory
Descri­ption
/etc
All sorts of system­-wide config­uration stuff
/proc/­cpuinfo
CPU info
/etc/p­asswd
User account info
/etc/group
Group info
/etc/s­hadow
Where passwords are actually kept
/etc/skel
Skeleton, template home directory for copying to make new home direct­ories
/etc/s­yst­emd­/system
Daemon config file / setup stuff
/etc/s­ysl­og.conf
Config­uration for syslog logging daemon
/var/log
Where logs are kept
/etc/hosts
Config­uration for network hosts
/etc/n­etworks
Config­uration for networks

Process Commands

Command
Descri­ption
Parame­ter­s/Usage
top
Displays and updates lots of info on running processes
prestres
Displays current running processes as a tree
fg
Foregr­ound; resume a suspended process or bring one back from the foreground
fg %[job number] or fg [process ID]
bg
Backgr­ound; puts a process into the background
Note: if you want to put a currently running command in the backgr­ound, use CTRL+Z, and then fg & bg
kill
Kills a command in the background

Automation and Daemons

Command
Descri­ption
Parameters
systemctl
Managing system­s/s­erv­ices, in particular daemons
journalctl
part of systemd, can be used to see loggin­g/e­rrors for daemons
crontab
Used for setting up automated running of commands / scripts at certain dates or intervals via cron
at
For scheduling a command to run just once
atq
Lists commands in the queue that have been scheduled to run
atrm
Remove a command from the queue
test
For checking files and values; any yes/no question about our system

Input / Reading Commands

Command
Descri­ption
Parameters
locate
For searching for files
find
For searching for files
less
Text viewer for viewing large files
nano
Good, simple text editor
vim
Complex, powerful text editor
vimtutor
Used for learning vim
cat
Concat­enate files and print them to stdout
echo
Echoes whatever it is given; useful for sending text somewhere
head
Read first few lines of a file and print them to stdout
n: number of lines to read
tail
Read last few lines of a file and print them to stdout
n: number of lines to read
awk
Used for viewing files in complex ways, like looping through a file and only looking at certain patterns and column­s/rows in a file
dd
Reads bytes from a location
 

Groups, Users, and Permis­sions oh my

Command
Descri­ption
Parameters
passwd
For changing and setting passwords
useradd
For adding a new user
su
Switch user
usermod
Modify a user account
chown
For changing ownership of a file / directory
chmod
For changing permis­sions of a file / directory
groupadd
Add a group

Syntax & Jargon

Symbol / Term
Descri­ption
stdin
Standard input; the input a command is looking to for what it should work with. Generally comes from keyboard; could be a file or something else, if we redirect stuff
stdout
Standard output; typically is the console. Can be changed to a file or something if we redirect it.
stderr
Standard error; where errors are printed to.
|
Pipe. Used to send output of one command directly to another like, "­history | less"
>
Send output of command somewhere.
>>
Append output somewhere.
>& or &>
Send stdout and stderr somewhere
2>
Send just stderr somewhere
1>
Send just stdout somewhere
&
Put at the end of a command to run it in the backgr­ound, immedi­ately returning console to you.
$
When on prompt, means that you're a regular user
#
When on prompt, means that you're the root user
?
Wildcard character - when a command receives '?' in its input, it will take that mean to any single character
*
Wildcard for any number of charac­ters. I.e. "­*.t­xt" would refer to any thing/file ending in ".tx­t"
[abc]
Wildcard for given characters (here, a, b, or c). Can also define a range, i.e. [1-3]
CTRL+U
Delete current line
CTRL+C
Abort whatever's currently running
CTRL+Z
Suspend whatever's currently running

Miscel­laneous Commands

Command
Descri­ption
Parameters
yes
Spams a string until forcibly stopped
sudo
Runs the given command as root
shutdown
Shuts down system
"­shu­tdown now" to do it now
halt
Shuts down system
p: needed on most systems to power down hardware
reboot
Same as halt but reboots
which
Finds if a command exists and where it is
whereis
Like which but searches a broader area than just your shell's search path
sort
Sorts text
r: reverses sort order. h: for sorting human-­rea­dable byte counts
ln
Used for creating links between files; shortcuts basically
chsh
Change shell
stty
Setting key commands (like backspace to delete)
(Use "stty sane" to unbork a borked shell)
clear
Clears terminal of text
script
Saves everything that comes up in your console, until exit is called
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Linux, Bash, and System Administration Cheat Sheet