Linux BASH commands Flashcards
ls
list
man
manual
apropos + “…”
search for this phrase
Ctrl + C
cancel command
Ctrl + A
go to beginning of line
Ctrl + E
go to end of line
f
go forward in manual
b
go backward in manual
cd
change directory
tab
autofill command
pwd
Print Name of Working Directory
ls -R + argument
search directory and print its documents
(recursive)
mkdir
make new directory
mkdir -p
create necessary parent directories
rmdir
remove directory
(directory must be empty)
cp
copy
cd ..
move up one directory
mv
move
mv (file) .
move to current working directory
mv *.txt (directory)
move all text files to specified directory
mv (directory/)* .
move to current working directory
rm
remove
?
(linux)
one character
find + directory + search criteria (eg. -name) + search term (eg. “poe*”)
find file
su + username + user password
switch user
sudo -k
end admin root privileges
(will need to enter password again)
sudo -s
log into root shell
rwx
read (read only)
write (write only)
execute (run the file)
chmod
changes permission mode string (eg. rwx)
chown
change owner
chgroup
change group
touch
create new file
nano test.sh
edit test.sh file
ln -s
symbolic (soft) link
ln
absolute path (hard) link
echo
prints out whatever text you give as an argument
(eg. echo “Hello” outputs Hello
(symbol)
pipe to connect commands
wc
word count
cat
concatenate
head
outputs first 10 lines of text
tail
outputs last 10 lines of text
-n(number)
specify to head or tail command how many lines to output
-n
adds line number to each line of text
less
displays text one page/screenful at a time and provides navigation controls.
Can use same controls as for manual
grep
searches files for matching patterns
(eg. grep “the” poems.txt)
-i
case insensitive for pattern
-v
omit lines with the pattern
-E
using regex (eg. grep -E “\w{6,}” poems.txt
highlights any word at least 6 word characters long
sort -n
sort numerically
sed s/old data/new data file.txt
substitute new for old in simple text file
sort
sorts by first column data
sort -k
sort by sort key
sort -k2 -n
sort 2nd column numerically
sort -u
only unique lines, removes duplicates
rev
prints text in reverse sequence
tac
concatenates or displays files in reverse
tr
translates or modifies individual characters according to parameters
VIM
text editor
i
(VIM)
insertion mode
esc
(VIM)
go back to command mode
I
(VIM)
insert at beginning of line
:w new.txt
(VIM)
saving new file
:wq
(VIM)
save and quit
G
move to bottom of file
1G
move to top of file
( or )
move forwards and backwards by line
{ or }
move forwards or backwards by paragraph
:q!
(VIM)
quit without saving
o
insert on following line
nano
lightweight text editor
includes command legend on screen
ctrl + w
(nano)
search text for wordc
ctrl + v
(nano)
move down a screen
ctrl + y
(nano)
move up a screen