Linux Commands Flashcards
date
displays today’s date
cal
displays current month
df
displays the current amount of free space on disk drives
free
displays the amount of free memory
exit
to end terminal session
CTRL-D
command to end terminal session
pwd
print working directory
cd
change working directory to home directory
cd ..
change to parent directory
cd -
change to previous directory
cd ~user_name
change to home directory of user_name
ls
list files and directories
ls -a (–all)
list all files including hidden ones
ls -A (–almost all)
like ls -a except for . current directory and .. parent directory
ls -d (–directory)
use with -l to view details of the diretory itself
ls -F (–classify)
appends indicator to each listed name (i.e., / if directory)
ls -h (–human-readable)
displays files sizes in human-readable in long format listings
ls -l
display listing in long format (with details)
ls -r (–reverse)
display results in reverse order
ls -S
display results by file size
ls -t
display results by modification time
file filename
determine file type
less filename
program to view text files
less etc/passwd
lists all the system’s user accounts
cp
copy files and/or directories
cp item1 item2
copies single file or directory item1 to file/directory item2
cp -a (–archive)
copy files and directories and all of their attributes, inculuding ownerships and permissions
cp -i (–interactive)
prompts for confirmation before overwriting exisiting file
cp -r (–recursive)
copy directories and their contents
cp -u (–update)
copies only newer copies of files or ones that do not exist in directory
cp -v (–verbose)
displays informative message as copy is performed
mv
move/rename files an/or directories (can be used with: -i, -u, -v)
mv item1 item2
renames item1 to item2
mv item1 directory
moves item1 to directory
mkdir
make directory
mkdir dir1 dir2
multiple directories can be created with one comand
rm
remove or delete files and directories (can be used with: -i, -r, -v)
rm -f (–force)
ignore nonexistent files and do not prompt
ln
create hard and symbolic links
ln file link
creates hard link
ln -s item link
creats symbolic link
type command
indicate how a command name is interpreted - it’s type
which command
display which executable program will be executed - it’s location
help command
get help for shell built-ins
command –help
displays a description of the command’s supported syntax and options - it’s usage
man program
display a program’s manual page
apropos command
display a list of appropiate commands
info program
display a program’s info entry – info pages are hyperlinks
whatis command
display one-line manual page descriptions
alias
create an alias for a command
alias name=’cmd1; cmd2; cmd3’
create alias name by connecting commands together (alias name=’string’)
unalias name
removes alias
alias (by itself)
reveals all aliases defined in the environment
cat filename
concatenate files
sort
sort lines of text
uniq
report or omit repeated lines
uniq -d
report list of duplicates
grep pattern filename
print lines matching a pattern
grep -i pattern filename
ignore case
grep -v pattern filename
print lines that do not match
wc
prints number of lines, words, and byte counts for each file
head filename
output first 10 lines of file; -n 5 (5 lines)
tail filename
output last 10 lines of file; -n 5 (5 lines)
tail -f filename
view file in real ltime; tail -f /car/log/messages (to view messages file)
tee
read from standard input and write to standard output and files
echo text
display a line of text
echo *
shell expands the wildcard * into the names of the files in the current working directory
echo letter*
files beginning with letter are expanded
echo *letter
files ending with letter are expanded
echo wildcards and character class
varous means of expansions
echo ~
tilde expansion: expands home directory
printen
print part or all of the environment
printenv | less
to see a list of available variables
$(command)
command substitution
ls -l $(which cp)
example of command substitution: get listing of cp program
file $(ls -d /usr/bin/* | grep zip)
example of command substitution: pipeline using grep
double quotes “ “
special characters used by the shell lose their special meaning except for $(dollar sign, (backslash), `(backtick)
single quotes ‘ ‘
supress all expansions
escape character \
used to prevent an expansion (echo “balance is $5.00”)
clear
clear the terminal screen
history
display history
history | less
view contents of the command history
!number
history expansion: example !88 expands the contents of the 88th line in the history list.
id
display user identity
chmod 766 file.txt
Change File Mode – using octal notation
su
run a shell as another user
su -
run a shell as superuser
sudo command
super user do – execute a command as a different user
chown [owner][:[group]] file
change file ownership and group
chown bob
change file ownership to bob
chown bob:users
change file ownership to bob and change file group ownership to users
chown :admins
change group ownership to admins. File ownership is unchanged.
chown bob:
change file ownership to bob and group owner to the login group of user bob
passwd
used to change your password
ps
report a snapshot of current processes
ps x
show all processes regardless of what terminal they are controlled by
ps aux
displays processes belonging to every user
pstree
process list arranged in -tree-like pattern
vmstat
snapshot of system resource usage
top
display tasks
jobs
list active jobs
bg
place a job in the background
fg
place a job in the foreground
kill PID
terminate process by PID
kill -l
display a list of kill signals
killall
kill processes by name
shutdown
shutdown or reboot system
set
set shell options
export
export environment to subsequently executed programs
apt install package_name
method used to install Debian packages (may require sudo command)
yum install package_name
method used to install Red Hat packages
sudo apt update
update Debian system
sudo apt upgrade
upgrade Debian system
yum update
update Red Hat system
apt remove package_name
remove Debian package
yum erase package_name
remove Red Hate package
dpkg
list installed packages - Debian
rpm -qa
list installed packages - Red Hat
apt-cache show package_name
display info about an installed package - Debian
yum info package_name
display info about an installed package - Red Hat
dpkg -S file_name
determine which package is reponsible for the installation of a particular file - Debain
rpm -qf file_name
determine which package is reponsible for the installation of a particular file - Red Hat
mount
mount a file system
unmount
unmount a file sytem
fsck
check and repair a file system
fdisk
manipulate disk partition table
mkfs
create a file system
dd
convert and copy a file
genisoimage (mkisofs)
create an ISO 9660 image file
wodim (cdrecord)
write data to optical storage media
md5sum
calculate an MD5 checksum
ping
send an ICMP ECHO_REQUEST to network hosts
traceroute
print the route packets trace to a network host
ip
show/manipulate routing, devices, policy, and tunnels
netstat
print network connections, routing tables, and more
netstat -ie
examine network interfaces in system
netstat -r
kernal’s network routing table
ftp
internet file transfer program
wget
non-interactive network downloader
ssh
OpenSSH SSH client (remote login program)
locate bin/zip
find files by name
find
search for files in a directory heirarchy
find ~
listing of home directory
find ~ | wc -l
pipe list into other programs; count number of files
find ~ -type -d | wc -l
pipe list into other programs; count number of diretories
find ~ -type -f | wc -l
pipe list into other programs; count number of regular files
xargs
build and execute command lines from standard input
touch
change file times
stat
display file or file system status