Commands summary

From Unix
Jump to navigation Jump to search

Unix architecture and file system

Unix Command Acronym translation Description
who or whoami - Tells you who the current user is. The 'who' command is not present in MobaXterm but you can use 'whoami' instead
man <COMMAND> Manual A very useful command. By using this command on other Unix commands, it gives you a manual of how to use them. This command is not present in MobaXterm, but you can instead use google to find command manuals.
cal [OPTION] Calendar Gives you the current date in a calendar form
date [OPTION] - Gives you the current date
pwd [OPTION] Print working directory Where are you? Shows the current directory
ls [OPTION] [DIRECTORY] List segments Shows the files in the current directory if a filepath is not given.
cd [OPTION] <DIRECTORY> Change Directory Moves you to a specified directory. You can type 'cd ..' to move one directory back. The '..' simply means to go up one level towards your root
mkdir [OPTION] <DIRECTORY>
Make directory Makes the specified directory
rmdir [OPTION] <DIRECTORY> Remove directory Removes the specified directory if it's empty. To remove a non-empty directory, one can use the recursive option 'r.
ln [OPTION] <DIRECTORY> <LINK_NAME> Link Can be used to create links (shortcuts) between files and directories.

Standard streams and working with files

Unix Command Acronym translation Description
touch [OPTION] <FILE> - Touches a file. If the file doesn't exist already it will create a file with the specified name. If it already exists it will update the date of the file
mv [OPTION] <FILE> <destination directory or another filename> Move Moves a file to a specified directory. It can also be used to rename files.
rm [OPTION] <FILE> Remove Removes specified file in current directory. This command can also be used to remove non-empty directories.
cp [OPTION] <FILE> <destination directory or another file> Copy Works a lot like mv, but moves a copy of the file instead. Can also be used copy the content of one file to another file.
cat [OPTION] <FILE> Concatenate Concatenates files and displays it in standard output. If used on one file, the content of that file is displayed in the command line interface.
head [OPTION] <FILE> - Outputs the first part of a file
tail [OPTION] <FILE> - Outputs the last part of a file
less <FILE> - Shows a screenfull of the file. This is a useful command for viewing big files as it loads at smalls segments at a time. q --> quit , space --> scroll forward one page , b --> scroll backward one page. Arrow keys can be used to scroll up and down one line at a time.
wc [OPTION] <FILE> Word count Counts the lines and words in the file/files, but can also count other things based on the options you give it.
paste [OPTION] <FILE> - Merges lines from different files.
cut [OPTION] <FILE> - Removes different parts of a file depending on on what is specified in the option.
echo [OPTION] <STRING> - Outputs the string to your command line interface. In computer language, a string is just a sequence of characters.
wget [OPTION] <URL> web get A non-interactive network downloader used to download files located at the URL.
curl [OPTION] <URL> client URL Similarly to wget, it is used to download files at the specified URL. This is an alternative MAC OS users, where wget doesn't work.
tee [OPTION] <FILE> It's named after the 'T-splitter' used in plumbing. Splits output so that it can be outputted to both the terminal and a file.

Text editors and some shell scripting

Unix Command Acronym translation Description
alias <alias_name>=<The stuff you want to make an alias for> - Creates an alias called alias_name for what you've inserted on the right side of '='
source <FILE> - Executes the contents of a file in current shell. Changes made when the file is run will be permanent until changed. It is synonymous with Prompt$ . <FILE>.
bash <FILE> Bourne again shell Bash will execute <FILE> as a different process. This way, changes that occur while the file is being executed cannot affect your shell.

Setting up your shell script

Unix Command Acronym translation Description
which <COMMAND> - Shows the full path to the command.
read [OPTION] [input1] [input2] [input3] - Can be used to prompt user for input and save them as variables [input1]..[input3].

Filtering and regular expressions

Unix Command Acronym translation Description
grep [PATTERN] <FILE> Global regular expression print. Uses regular expressions select lines in a file that matches the pattern.
sed [OPTION] <SCRIPT> <FILE> stream editor Allows user to edit files without actually opening the files using regular expressions.
tr [OPTION] <SET1> <SET2> Translate Translates characters from the standard input and writes to the standard output.
sort [OPTION] <FILE> - Sorts the content of a file.

File permissions

Unix Command Acronym translation Description
chmod [OPTION] [MODE] <FILE> Change mode. Changes file permissions on a file according to the mode given. No need to be confused about [MODE], as it just another term used for file permission. It can be specified with letters or numbers. It's easier to understand what you're doing with letters but using numbers can be faster. In the example, we'll show how to use both.
chown [OPTION] [OWNER][:[GROUP]] <FILE> Change owner. Change file owner and/or group. This can be done separately or simultaneously by typing [OWNER]:[GROUP].
chgrp [OPTION] <FILE> Change group. Change group of a file.

File compression and advanced packaging tools

Unix Command Acronym translation Description
tar [OPTION] <ARCHIVE> <FILES> Tape archive Archive utility tool, used to create and extract archives. Archives are simply multiple files that have been combined into one file.
gzip [OPTION] <FILE> GNU Zone informational Protocol. Compresses <FILE>
gunzip [OPTION] <FILE> GNU un Zone informational Protocol. Decompresses <FILE>
zip [OPTION] <FILE> Zone informational Protocol Archive and compression utility. Used to make an archive or compress <FILE>.
unzip un Zone informational Protocol Decompresses <FILE>
apt [OPTION] <PACKAGE> Advanced Packaging tool Package manager for Ubuntu with many utilities.

Processes: foreground and background, ps, top, kill, screen, nohup and daemons

Unix Command Acronym translation Description
<COMMAND> & - Runs command as a background process
bg %<PID> bg and PID are short for background and process identification respectively Continues a stopped job in the background
fg %<PID> fg and PID are short for foreground and process identification Continues a stopped job in the foreground
sleep <NUMBER>[s/m/h/d] - Delays for a specified amount of time. This can be specified <NUMBER> and suffixes; s, m, h and d which are short seconds, minuted, hours and days respectively. By default, the suffix is s
top [OPTION] - Displays all the processes running on your computer
ps [OPTION] Process status Reports a snapshot of current processes
kill [OPTION] <PID> - Sends a signal to a process and by default this signal is to terminate the process
screen [OPTION] - Used to create new terminal windows that are detached from each other. Child processes created within these new terminal windows are not affected if their parent process is terminated
disown - Dissociates process from current terminal session
nohup [OPTION] No hangup Used to run commands immune to hangups, ignoring stdin. By default output is redirected to nohup.out.
pstree Process tree Display a tree of parent and child processes

Understanding network and remote servers: IP/URL, ssh, scp, wget, curl

Unix Command Acronym translation Description
wget [OPTION] <URL> web get A non-interactive network downloader used to download files located at the URL.
curl [OPTION] <URL> Client url Similarly to wget, it is used to download files at the specified URL. This is an alternative MAC OS users, where wget doesn't work.
ssh <PORT> <user@IP/Domain_name> Secure shell Used to establish a secure connection to a remote server/system. It's also known as secure shell protocol.
scp <PORT> <user@IP/Domain_name> <user@IP/Domain_name> Secure copy protocol Starts a secure copy protocol, which copies files securely across from remote networks to clients or from clients to remote networks.
telnet <URL> <PORT> Teletype network Establishes a connection with the specified URL and port.
ifconfig [OPTION] Interface configuration Displays currently active networks but when used with a, it displays the status of all networks.
nslookup Name server lookup Used to obtain information about a server through a DNS (Domain name system) server.
ping [OPTION] <IP/URL> Packet Internet Groper Checks network connectivity between host (your computer) and host/server.