Appendix A — Syntax Reference
Help & Documentation
man
Interface to the on-line reference manuals.
help
Display help for built-in commands.
Files & Directories
cd
Change directory.
ls
List directory contents.
pwd
Print working directory.
mkdir
Create a directory.
tree
Display the directory structure of a path in a tree-like format, showing all the files and subdirectories under it.
cp
Copy files or directories.
mv
Move or rename files or directories.
rm
Remove files or directories. By default, rm
won’t remove a directory without the -R
or -r
option.
ln
Create links between files.
readlink
readlink
displays the target of a symbolic link.
touch
Create a new file or update the timestamp of existing files.
find
Search for files in a directory hierarchy.
locate
Find files by name quickly using a database.
file
Determine file type.
stat
Display file or file system status.
more
View file contents interactively.
more
iTerm2less
View file contents interactively.
less
iTerm2head
Output the first part of files.
tail
Output the last part of files.
System Administration
who
Show who is logged in.
whoami
Display current user name.
hostname
Show or set system’s network name.
chsh
Change a user’s default login shell.
date
Display or set the date and time.
uptime
Show how long the system has been running.
cal
Shows a calendar of the current month or a specified month and year.
df
Report file system disk space usage.
du
Show disk usage statistics.
ps
Report a snapshot of the current processes.
free
Displays the amount of free and used memory in the system, including physical memory (RAM) and swap space.
top
Display tasks and system status interactively.
top
in iTerm2iotop
Monitor disk I/O usage by processes.
htop
Interactive process viewer, similar to top
but more configurable.
vmstat
Report virtual memory statistics.
dmesg
Display the kernel-related messages.
clear
Clear the terminal screen.
yes
Output a string repeatedly until killed.
NOTE: Use Ctrl + C to interrupt the yes
command.
exit
Exits the shell or current command session.
xargs
Build and execute command lines from standard input.
crontop
Schedule periodic background work.
systemctl
Control the systemd system and service manager.
journalctl
Query and display messages from the journal.
Variables
set
set
is used to display all shell variables and functions, and to configure shell options and positional parameters.
unset
unset
is used to remove a shell or environment variable, effectively deleting it from the current shell session.
export
export
is used to set an environment variable and make it available to child processes spawned from the current shell session.
Text Processing
cat
Concatenate files and print on the standard output.
echo
Outputs the strings it is given to the terminal.
grep
Print lines matching a pattern.
sort
Sort lines of text files.
uniq
Report or omit repeated lines.
cut
Remove sections from each line of files.
paste
Merge lines of files.
join
Join lines of two files on a common field.
comm
Compare two sorted files line by line.
diff
Compare files line by line.
wc
Print newline, word, and byte counts for each file.
seq
The seq
command generates a sequence of numbers, with customizable start, stop, and step values, and outputs them to standard output.
sed
Stream editor for filtering and transforming text.
awk
Programming language for data extraction and reporting.
Networking
ping
Check the network connection to another host.
netstat
Display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
ss
Utility to investigate sockets.
ifconfig
Configure or display network interface parameters for a network using TCP/IP.
traceroute
Print the route packets take to network host.
File Archiving & Transfer
tar
Store and extract files from a tape or disk archive.
gzip
Compress or expand files.
zip
Package and compress (archive) files.
scp
Secure copy (remote file copy program).
rsync
Fast, versatile, remote (and local) file-copying tool.
User Management
chown
The chown
command changes the owner and/or group of specified files or directories, thereby altering who has control over these resources.
chmod
The chmod
command changes the access permissions of file system objects (files and directories), allowing users to specify who can read, write, or execute them.
sudo
Execute a command as another user, typically the superuser.
useradd
Create a new user or update default new user information.
usermod
Modify a user’s system information.
userdel
Delete a user account and related files.
groupadd
Create a new group.
passwd
Update a user’s authentication tokens/password.
Disk Management
fdisk
Partition table manipulator for Linux.
parted
A partition manipulation program.
mkfs
Build a Linux filesystem on a device, usually a hard disk partition.
mount
Mount a filesystem.
umount
Unmount file systems.