Linux Command Cheat Sheet: File Commands (Cont.) Most Used Network Diagnostic Commands (Cont.)
Linux Command Cheat Sheet: File Commands (Cont.) Most Used Network Diagnostic Commands (Cont.)
NETWORK DIAGNOSTIC COMMANDS ssh -i ~/.ssh/specific_ssh_fkey Specify other ssh key for connection
rmdir Remove an empty directory
ifconfig/ip Get the IP address, MAC address, and MTU of
cp [file_name1] [file_name2] Copy the contents of the first file to a new
available networks
destination, which can be in a second folder PIPES/REDIRECTION
ping [address] Send ICMP ECHO_REQUEST packets to
cp -r [directory_name1] Recursively copy the contents of the first > Represents output redirection and redirects
[directory_name2] directory into the second directory network host at [address]
output to a file and overwriting the file
mv [file_name1] [file_name2] Move file_name1 to file_name2 nslookup [address] Use the IP address to discover a domain
>> Redirects output to a file and appends the
name, or vice versa.
redirected output rather than overwrites
ln -s /path/to/[file_name] [link_name] Create a symbolic link to a file
nettop Monitor network activity, showing a list of
< Represents input redirection and redirects
touch [file_name] Create a new file processes and corresponding process IDs
the given input file
with network connections
head [file_name] Show the first 10 lines of a file
<< Launch a file and and captures user input
netstat Display which ports are active on your
tail [file_name] Show the last 10 lines of a file until EOF
machine, their status, and what they're
gpg -c [file_name] Encrypt a file connected to | (ex. command_1 | command_2 | A Linux pipe is a form of redirection used to
command_3) combine two or more commands where the
gpg [file_name.gpg] Decrypt a file dig [record type] [domain] Gather information about a particular
output of one command acts as the input of
domain. Try “dig txt google.com”
the next command in the sequence.
wc Print the number of words, lines, and bytes in
a file
Linux Command Cheat Sheet
SYSTEM INFORMATION USER CONTROLS AND MANAGEMENT USER WARNING: SOME OF OTHER
lshw | less List all hardware and pipes to the less
THESE COMMANDS CAN BE DANGEROUS. USE WITH CAUTION. history Display prior used commands
command for easy reading and pagination useradd [user_name] Create a new user
[tab] Autocomplete command you are typing, if
top Display sorted information about useradd –r [user_name] Delete a user autocomplete has been configured for
processes your shell session.
passwd Change your password
free Free shows system information such as man [command name] Display the manual or help file for a
free memory and swap in kibibytes chown user:group /path/to/file Change ownership of a file command
swapon -s Swap information chown –R user:group /path/to/directory Change the ownership of a directory and clear Clear all information from the terminal
files window. Not useful for security.
dmidecode | less Summarize BIOS information
chmod [permission] [file_name] Change the permissions of a file env Display environment variables
cat /etc/issue The cat command shows information Eg. chmod 777 /path/to/file
about a given directory, in this cat /ect/ export [variable_name]=[variable_value] Create a new environment variable
issue. quit Logout
unset [variable_name] Remove environment variable
lspci (or -v for verbose) Show information about all PCI w Display currently logged in users
at [-V] [-q queue] [-f file] [-mldbv] TIME Run a command at a specific time
lsusb (or -v for verbose) Show information about all usb devices. chroot [path] [command] Change the root directory of a process
crontab –e Create a new crontab or edit an existing
df –m Display free storage in megabytes finger [username] Display information about a user crontab
du Return disk usage groups [username] Display the groups a user belongs to date Display current system date and time
du –h [directory] Return disk usage in a readable file size sudo passwd root Set a new password for the root user, iostat List CPU and I/O statistics
format Eg. 1.1K or 15M 1.5G (-m shows file can be used to circumvent the sudo
command alias [new command name]=[command] Create a temporary alias for a command
in megabytes and -g shows a file in
gigabytes)
(sudo) service ssh start Start ssh service shutdown Turns a computer off