Linux Flashcards
what does $pwd do
print working directory
what does $hostname do
my computer’s network name
what does $mkdir do?
make directory
what does $cd foo/ do
change directory to foo
what does $rmdir foo do
remove directory foo
what does $pushd do
push directory
what does $popd do
pop directory
what does $cp do?
copy file or directory
xargs
execute arguments
find
find files
grep
find things inside files
man
read a manual page
apropos
find what man page is appropriate
env
look at your environment
echo
print some arguments
export
export/set a new environment variable
what does $exit do?
exit the shell
sudo
DANGER! become super user root
What does Bash stand for?
Born again shell
what does $ls -a do?
list all files in the directory including hidden files.
what does $ls -l do?
list all files in the directory with detailed information
what does $ls -R do?
list all files recursively in directory and sub-directories
what does $ls -r do?
lists all files in the directory in reverse order
what does $ls -t do?
lists files by modification time
what does $touch foo do?
creates a new file foo
what does $file foo.bar do?
tells what type of file foo is
what does $cat foo.bar do
displays the contents of foo
what does $less foo.bar do?
allows navigation through file foo
what does $history do?
displays a history of commands
what does $clear do
clears the terminal
what does $cp foo.bar /new do?
copies foo.bar to directory new
what does $cp *.jpg Pictures/ do?
copies all files with the extension .jpg to the Pictures directory
what does $cp -r Pictures/ Downloads do?
copies all files from Pictures to Downloads overwrites any matching files
what does $cp -i foo.bar Documents/ do?
copies foo.bar to Documents directory but prompts before overwriting a similar file
what does $mv oldfile newfile do?
renames oldfile as newfile
what does $mv oldfile Stuff/ do?
moves oldfile to directory Stuff
what does $mv Things/ Stuff/ do?
renames Things to Stuff
what does $mkdir books paintings do?
makes a books directory and a paintings directory
what does $mkdir music/rock/punk/ do?
makes a directory music with a sub-directory rock which has a sub-directory punk
what does $rm file1 do?
permanently deletes file1
what does $rm -f file1 do?
force deletes file1 even if it is protected
what does $rm -r stuff/ do?
deletes the directory stuff and all of its files
what does rmdir stuff/ do?
removes the directory stuff only if it is empty
what does $find things/ file1 do?
finds a file named file1 in the things directory
what does $find -type d do?
finds all directories and sub directories
what does $help echo do?
displays a description and options for the echo command
what does $foo –help do?
displays a description and options for the executable foo
what does $man ls do?
displays a detailed manual for the ls command
what does $whatis ls do?
displays a brief description of the ls command
what does alias foobar=’ls -a’ do?
creates an alias that allows the commands ‘ls -la’ to be run by typing foobar
what does unalias foobar do?
removes the alias foobar
what does echo Hello World > peanuts.txt do?
overwrites any existing peanuts.txt with Hello World
what does echo Hello World»_space; peanuts.txt do?
appends Hello World to the contents of peanuts.txt
what does $ls /fake/directory 2> peanuts.txt do?
redirects the error message to peanuts.txt
in bash what is the re-director for stdout
>
in bash what is the redirect for stdin
<
in bash what is the redirect for stderr
2>
in bash what key represents the pipe operator
|
what does $ls -la /etc | less do?
pipes the command to less
what does $ ls | tee peanuts.txt do?
outputs ls to console and writes it to peanuts.txt
what does $ env do?
displays your environment variables
what does $ cut -c 5 sample.txt do?
outputs the 5th character of sample.txt
what does cut -f 1 -d “;” sample.text do?
prints the text before the first semi-colon in sample.txt
what does $ head foo do?
shows the first 10 lines of foo
what does $ head -n 15 foo do?
shows the first 15 lines of foo
what does $tail foo do?
displays the last 10 lines of foo
what does $ tail -f foo do?
follows the last line of foo as it grows
what does $ expand foo do?
prints the output of foo with each tab converted into a number of spaces
what does $ join foo bar do?
joins an order list from foo with an ordered list from bar
what does $split foo do?
splits foo into separate 1000 line files
what does $ sort foo do?
sorts the contents of foo (i.e. alphabetical order)
what does $ tr a-z A-Z do?
translates input to all caps
what does $ wc foo do?
gets the word count of foo
wat does $ nl foo do?
gets the line count for foo
what does $grep foo bar.txt do?
finds instances of foo in bar
what does $sudo foo do?
performs task foo with root privilages
what does $ visudo do?
allows you to see and edit super users in the /etc/sudoers file
what does $ chmod user2 +x myfile do?
adds executable permission for user2 to myfile.
what does $ chmod user2 -w myflie do?
removes write permissions for user2 from myfile
what does $ chmod user1user2 +r myfile do?
adds read permission for user1 and user2 to myfile
what does $ sudo chown patty myfile do?
changes the owner of myfile to patty
what does $ sudo chgrp whales myfile do?
changes group ownership of myfile to whales
what does $ sudo chown patty:whales myfile do?
changes the ownership of myfile to patty and to the whales group
what does $ umask do?
changes default permissions
what does $ ps do?
shows a a quick snapshot of the current processes.
what does $ ps a do?
lists all processes including those being run by other users
what does $ ps u do?
show more detail about processes
what does $ ps x do?
shows all process that don’t have a TTY associated with them?
what does $ top do?
gives real time information about the processes being run
what does tty2 in the TTY field mean
process controlled by second terminal device
what does pts/* in the TTY field mean
process controlled by a pseudo terminal device
what does ? in TTY field mean
process has no controlling device
after the _exit system call what is the termination status for success
0
what is the master process called
init
when is an orphan process created
when a parent process dies before a child process
when is a zombie process created
when a child process terminates and the parent process hasn’t called wait
what is SIGHUP?
hangup, sent to a process when the controlling terminal is closed
what is SIGINT
an interrupt signal sent when Ctrl-C is used to kill a process
what is SIGTERM
signal to kill a process but allow it to do clean up first
what is SIGKILL
signal to kill a process with no cleanup
what is SIGSTOP?
signal to stop/suspend a process
what is the default signal to kill a process?
SIGTERM
how does a niceness number affect a process
a lower number gives the process a higher CPU priority
what does $ nice -n 5 apt upgrade do?
sets the niceness of apt upgrade to 5
What dos process STAT R mean
running or runable
What does process STAT S mean
Interruptible sleep
What does process STAT D mean
Uninterruptible sleep
What does process STAT Z mean
Zombie
What does process STAT T mean
suspended/stopped
where in the file system are processes stored?
/proc
what does $ sleep 1000 & do?
sends process 1000 to run as a background job
what does $ jobs do?
lists the background jobs
what does $ fg %1 do?
returns background job 1 to the foreground
what does kill %1 do?
kills background job 1
what does $ gzip myfile do?
compresses myfile
what does $ gunzip myfile.gz do?
unzips myfile.gz
what does $ tar cvf mytarfile.tar file1 file2 do?
creates an archive containing file1 and file2
what does tar xvf mytarfile.tar do?
unpacks mytarfile
what does $ tar czf myfile.tar.gz do?
creates a compressed tar file
what does $ tar xzf file.tar do?
unpacks and extracts the contents of the tar file
what does $ dpkg -i foo.deb do?
installs foo.deb package
what does rpm -i foo.rpm do?
installs the foo.rpm package
what does $ dpkg -r foo.deb do?
removes foo.deb package
what does $ rpm -e foo.rpm do?
removes the foo.rpm package