The Linux command line interface (CLI) is a text-based interface for interacting with the operating system. It is an alternative to the graphical user interface (GUI) that is commonly used on most personal computers.

One of the main advantages of the CLI is that it allows users to perform tasks with greater efficiency and speed, as it allows users to enter commands directly rather than using a mouse to navigate through menus and options. It is also more flexible, as users can combine multiple commands to create complex scripts that automate repetitive tasks.

The CLI is particularly useful for administrators and power users who need to perform advanced tasks such as managing servers, configuring network settings, and managing large amounts of data. It is also useful for developers who need to work with code and perform version control tasks.

Overall, the Linux CLI is a powerful tool that allows users to efficiently and effectively interact with the operating system and perform a wide range of tasks.



Basic Commands

Commands Description Example
date print or set the system date and time date
wget The non-interactive network downloader wget [<https://gitlab.com/questra-digital/vanguards-in-training/batch-fall-2022/example_project>](<https://gitlab.com/questra-digital/vanguards-in-training/batch-fall-2022/example_project/-/tree/master>)
unzip list, test and extract compressed files in a ZIP archive unzip example-project
ls list directory contents `ls
ls lesson-01 # prints all the files in lesson-01 directory
ls lesson-01/*.csv # prints all the files in lesson-01 directory with .csv extension
ls -R d1 # list directory recusrsively`
ls *.csv # shows every file in the working directory with .csv extension ls -lh # show detailed listing
clear clear the terminal screen clear
cd change directory `cd lesson-01 # change directory to lesson-01
cd .. # change to previous directory
cd - # change to last working directory
cd d1/d2/d3 # change to d3 which is in d2 which is in d1`
mkdir make directory `mkdir d1 # creates directory named d1
mkdir -p d1/d2/d3 # creates hierarchy of directory`
pwd print name of current/working directory pwd
touch change file timestamps touch file-1 # creates a file of name file-1 if it does not exist
cat concatenate files and print on the standard output cat basic-commands # enter the file name after cat, in this case basic-commands
wc print newline, word, and byte counts for each file wc basic-commands # enter the file name after cat, in this case basic-commands
whatis display one-line manual page descriptions whatis wc #enter the command after whatis
man an interface to the system reference manuals man wc #enter the command after whatis
history GNU History Library history # prints every command executed with its specific id
! shortcut to enter previous commands again !540 # executes the command with id 540
!! repeat the previous command !!

Interprocess Communication

Commands Description Example
head output the first part of the files head iris.csv
` ` pipe symbol takes the output from one file and inputs to another
grep print lines that match patterns `grep “setosa” iris.csv # prints line that matches setosa in iris.csv files
cat iris.csv grep “setosa” # same as grep “setosa” iris.csv
cat iris.csv grep “setosa” wc # counts words of cat iris.csv
cat iris.csv grep "set" grep "3.5"
ls grep csv # prints files having csv in name`
`cat iris.csv grep “setosa” > setosa.csv # write lines having the word setosa in the file iris.csv to setosa.csv`
grep -r “setosa” # Find in files (dot for current directory)
echo display a line of text `echo “something”
echo “something” > temp.txt`
mv move (rename) files mv setosat.csv setosa.csv
rm remove files or directories `rm temp.txt # remove a file
rm -r backup # remove a directory`

Disk Usage & Working with Multiple Files

Commands Description Example
cp copy files and directories `cp backup-file backup-file-02 # copy a file
cp -r backup-directory backup-directory-02 # copy a directory`
df report file system disk space usage df -h # Show disk usage
du estimate file space usage `du -h # Human readable
du -sh # Summary
du -sh * # Summary for subfolders`
find Search for files in a directory hierarchy `find . -name “ *.csv”
find . -type f -size +100k`

Process & System

Commands Description Example
tail output the last part of files `tail lesson-04/housing-data/au5_500.csv
tail -f hello.txt # Follow a file for changes, Ctrl + C to quit`
ps report a snapshot of the current processes `ps u # Show current user’s processes
ps au # Show all users’ processes
ps au # Show in BSD format
ps aux grep firefox # find ‘firefox’ in the process list`
kill send a signal to a process kill -9 3245 # Kill process with id 3245
killall kill processes by name killall firefox
cat /proc/cpuinfo Get CPU info cat /proc/cpuinfo

Networking Commands

Commands Description Example
ifconfig configure a network interface ifconfig
nslookup query Internet name servers interactively nslookup yahoo.com
netstat Print network connections, routing tables, interface statis‐
tics, masquerade connections, and multicast memberships netstat -ntlp
netstat -ntlp grep 22 # Check if ssh (port 22) is open

VIM Commands

# [In Command Mode]
:q     # Quit
:wq    # Write file and quit
:q!    # Quit without saving changes
i      # Go to insert mode
INSERT # Go to insert mode

# Show line numbers
:set number

# Go to end of file
Shift + G

:0     # Go to line number 0
0      # Go to beginning of line

:100   # Go to line 100

/num   # Search for ‘num’
n      # After search, find next

dd     # Delete line under cursor
d10d   # Delete 10 lines
x      # Delete character under cursor
dw     # Delete word
yy     # Copy line
p      # Paste
.      # Repeat last operation
u      # Undo last operation

fH     # Go forward to character ’H’
FH     # Go backwards to character ’H’
%      # Go to matching bracket
vi"    # Select inside double quotes

# [In Insert Mode]
ESC    # Go to command mode