Shared Flashcard Set

Details

Unix Commands
unix commands
102
Computer Science
Not Applicable
01/31/2017

Additional Computer Science Flashcards

 


 

Cards

Term
touch
Definition
creates an empty file
Term
pwd
Definition
print working directory
Term
cd dir
cd ..
cd /
Definition
changes into the dir directory
goes one directory above the current directory
goes into the root directory
Term
cd ~
cd $HOME
Definition
both take you to the $HOME directory
Term
mkdir
mkdir -p
Definition
make a directory
makes all the directories including the parent ones
Term
tree
Definition
display the current directory contents/structure
Term
man, info
Definition
stands for manual and when put in front of a keyword will show the manual for that command
Term
CursorUp
Definition
retrieves commands already run
Term
Tab
Definition
auto-complete
Term
cp
Definition
copies a file and puts it in the new place. Cant copy a directory by itself it needs to be done recursively.

cp love ~/films/hate rename the copied file in the new place
Term
ls
Definition
list all the files in the current directory
Term
ls -a
Definition
lists all the files including the invisible stuff
Term
mv
Definition
move and/or rename
mv firstname newname
Term
rm filename
rm -i filename
rm -v filename
rm -r
rmdir
Definition
removes file immediately
gives you option about whether you want to remove file and then removes it
gives you feedback on what happened

--
removes directories
Term
brace expansion
touch f{1,2,4}
touch g{2..5}
Definition
using the curly braces to get a range of things repeating
num..num only works for letters and numbers, not roman numerals
Term
Glob Matching
*
Definition
match anything including nothing
Term
Glob Matching
?
Definition
match single character, must have character to match
Term
[aei]
Definition
match each individual character
Term
[0-9]
Definition
matches characters in the range
Term
[^aei]
Definition
match all but included characters
Term
[^0-6]
Definition
match all characters except those in the range
Term
editing files with vim i
Definition
insert mode
use esc to go back to command mode
Term
editing files vim
dd
Definition
delete lines
4dd - delete 4 lines
Term
editing files vim
dw
Definition
delete word
4dw d4w deletes 4 words
Term
editing files with vim
x
Definition
delete letter
Term
editing with vim
p
Definition
means paste
lowercase p means paste below current line
uppercase p means paste above current line
Term
editing with vim
i
Definition
insert before cursor
Term
I (upper case "eye" )
Definition
insert at start of line
Term
editing with vim
a
Definition
lower case a - append after cursor
Term
editing with vim
A
Definition
upper case A - append to end of line
Term
editing with vim
u
Definition
undo
Term
editing with vim
CTRL -r
Definition
redo
Term
editing with vim
/xyz
Definition
search for "xyz" n for next
Term
editing with vim
.
Definition
do the last command again
Term
editing with vim
hjkl
Definition
left cursor, cursor down, cursor up, cursor right
Term
editiing with vim
shift zz
Definition
save and exit
Term
editing with vim command mode
:w
Definition
write or save
Term
:q
Definition
quit
Term
:q!
Definition
Yes I'm sure I want to quit without saving
Term
:wq
Definition
write and quit
Term
:x
Definition
write and quit
Term
cat
Definition
concatenate files
Term
more filename
Definition
shows everything in the file. shows how much percentage wise youre through. once you scroll you can't get back to where you were.
Term
less filename
Definition
just like more except you can scroll up and down
Term
What can we do to insert multiple commands on the same line?
Definition
;
echo hello;echo hello
Term
head
Definition
on it's own its the first ten lines of a file
Term
head -n 10
Definition
first whatever number of lines
Term
tail
Definition
last 10 lines by itself
Term
cut -d ":" -f2 accounts
Definition
cut grabs a certain part of the file needs the column number and the file name as well as a deliminator when using -d
Term
fgrep
Definition
fixed search, searches each line for a word could bee a part of a word as well
Term
sort
Definition
sorts alphabetically by default
alphabetically by first character doesn't care if it's a number
Term
sort -g
Definition
generic numeric sort.
if you have both nums and letters it does both
Term
uniq
Definition
report or omit repeated lines. usually omits them
Term
wc
Definition
word count

-l for lines
-w for words
-m for characters
-c for bytes
Term
>
Definition
takes the output before it and put it in a file
this overrides what's currently int he file
Term
>>
Definition
takes the output before it and put it in a file. it appends itself to the current file
Term
echo -n
Definition
makes it so it's all on one line
Term
tee -a
Definition
also appends whatever is before it to a file
Term
cat accounts | wc -l
Definition
if you dont want to display the filename
Term
ls -l
Definition
stands for long listing and gives you the read, write, execute of all the users, group, and other
Term
chmod
Definition
gives read, write, execute powers
Term
chmod g -w
Definition
group can't write
Term
chmod u +r
Definition
user can now read
Term
chmod a + x
Definition
all users can execute all files
Term
chmod can also use numbers
Definition
read - 4 write -2 execute - 1 so if a user has all permissions and group has read and others none it' be 640
Term
ln
Definition
makes links between files
Term
hardlink
Definition
once you make a hardlink it doesn't care about the original

ln hellofile linkname
Term
difference between hardlink and copy
Definition
copy makes a copy and the newfile doesn't point to the old file content

whereas when they are linked the new link points directly to the content
Term
softlink
Definition
ln -s

different inode , not looking at inode but file path
Term
readlink -e
Definition
what is the original file path
Term
readlink -m
Definition
gives the path of whtaever you feed into it but PLOT TWIST it doesn't check for existing items
Term
basename
Definition
name of the file itself
Term
dirname
Definition
full path
Term
find ~ -name
Definition
if you're lookin for name say name and if type say type
Term
find ~ -mtime -1
Definition
less than 24 hours
Term
find ~ -mtime 1
Definition
exactly 24 hours
Term
find ~-mtime +1
Definition
more than 24 hrs
Term
grep -w
Definition
just grabbing the word
Term
grep -n
Definition
line number
Term
grep -c
Definition
# of lines with that word on it
Term
grep -v
Definition
any line that doesn't cntain that word it's the inverse
Term
grep -i
Definition
doesn't care about capitalization
Term
regex
Definition
^ start of the line
$ eend of the line
* the thing directly before it 0 or more times
Term
variable spacing
Definition
THERE CANNOT BE A SPACE NEAR THE EQUALS SIGN
Term
difference between " " and ''
Definition
unix knows "" has to apply rules
unix '' has it be literal
Term
${varname}
Definition
lets you get away with not having a space
Term
${#varname}
Definition
gets the amount of chars in that variable
Term
do decimals truncate or round
Definition
DECIMALS TRUNCATE NOT ROUND
Term
what do strings equal in math?
Definition
zero
Term
what do you need to use if you want decimals?
Definition
Bench calculator!
Term
ps
Definition
shows the processes that you the user are currently running
Term
pid
Definition
process id
Term
ppid
Definition
parent process id
Term
forest
Definition

is like tree but for processes

 

ps --forest

Term
kill
Definition
kill pid
kill %job#
Term
which
Definition
shows you where the command is stored
Term
who
Definition
who's logged into the system when and where
Term
man finger
Definition
finger firstname.lastname

gives you more info than who
Term
environment varable
Definition

exist across multiple shells

 

env

Term
rm -r
Definition
removes a direectory recursively
Term
file 2> /dev/null
Definition
throw the errors away that the thing is going to give
Term
sh listFiles
Definition
sh run a script
Supporting users have an ad free experience!