Linux / Bash Flashcards
[your app/program] –version
returns the version of the program you have installed
touch [file name].[file type is optional]
creates that file in current directory
in vim:
i
enters INSERT mode where you can edit the file
in vim:
:wq
exits INSERT mode and saves the file changes
in vim:
:q
exits INSERT mode and does not save file changes
what kind of file is .md ?
markdown file
clear
clears the shell
CTRL L
clears the shell
CTRL D
logs out
open .
opens the current directory into a new graphical window (in Finder)
CTRL A
brings cursor to START of line
CTRL E
brings cursor to the END of line
CTRL U
delete LEFT of cursor
CTRL K
delete RIGHT of cursor
CTRL W
delete WORD on LEFT
CTRL Y
PASTE (after U, K, or W)
TAB
autocomplete
!!
REPEAT last command
CTRL Z
STOPS current command or process
ls
lists files in current directory
ls -all
lists all files in current directory with all permisions and all metadata
ls -a
lists all files and folders (even hidden ones)
ls [some directory]
lists files in specific directory
cd [some directory]
changes directory
cd /
goes to root directory
cd ..
goes up one folder
cd ../../../
goes up three folders
pwd
prints current working directory or path
man [some command]
explains the command and any options it might have
cat [file name]
shows the contents of a file
cat > [some filename]
opens up text editor to add text to that file, or create a new file it that name doesn’t exist
head [file name]
prints only the top lines (use “head -n #” where # is number of lines from top)
tail [file name]
prints only the last lines (use “tail -n #” where # is number of lines from bottom)
mkdir [file name]
creates a new folder
mkdir [1stFolder/2ndFolder/file name] ..
creates new folder in the specific path
cp [file] [newfilename]
copies and renames file
cp [file] [path]
copies a file to that path
cp -R [folder] [newFolder]
copies and renames a folder
cp *.txt somePath/
copies all files of that type to that folder
mv [file] somePath/
moves a file to a folder
mv [folder] [newFolder]
moves a folder inside another folder
mv [file name] [new file name]
renames a file
mv [folder name]
moves the folder up one in the hierarchy
rm [file]
deletes the file
rm -i [file]
asks for permission before deleting file
rm -f [file]
forces the deletion of a file
rm -r [directory/]
deletes a folder
touch [file name]
creates or updates a file
ln file1 file2
physically links two files
ln -s file1 file2
symbolically (weak) links two files
find someText
searches all the CONTENTS of all the files in the current folder for that text
find -name [file name] someText
searches for that text in that specific file
find -name “text”
searches for files who start with the word text
find -type d someText
searches only directories
find -type f
searches only files
grep someText [file name]
searches for text in a file (-i = doesn’t consider case) and returns any line that matches that text
cd ~/someFolder
move back to this folder relative to anything (used if you don’t know where you are at)
chmod 777 [file name]
changes permissiono so anyone can read, write, and execute file
chmod 755 [file name]
changes permissions so that files can be readable and executable by others, but only changeable by user
chmod 700 [file name]
only the user can do anything to the file
grep -r text folderName/
searches file names for that text
grep -E ^text folderName/
searches fileNames that BEGIN with that text
grep -E <0-4> fileName
show lines containing the numbers 0-4
grep -E fileName
retrieves all lines with alphabetical letters
grep -r text
searches for tha ttext recursively throughout the files in the folders and parent folders
grep texts *.txt
searches that text in every .txt file
grep “sometext.someothertext”
searches for the beginning text, then any single character can be placed in the middle, and then the exact some other text after it
grep “someText*”
searches for the someText any number of consecutive times (so grep “.*” searches for anything that repeats any number of times)
grep -i “sometext”
searches for that text where case doesn’t matter
grep “text$”
searches for that text at the END of a line
grep “\
searches for text at beginning of word
grep “text>”
searches for text at end of word
grep “text?”
searches for text at most once
grep “text*”
searches for text zero or more times
grep “text+”
searches for text one or more times
grep “text{n}”
searches for text exactly n times
grep “text{n,}”
searches for text at least n times
grep “text{n,m}”
searches for text at least n times, and at most m times
someCommand | nextCommand
pipes the output of first command into the second
sort fileName
sorts the contents of the file
sort -r fileName
sorts in reverse
sort -n
sorts numbers
wc
prints word count (-l for lines, -w for words, -c for characters)
date
view and modify the time on your computer
at [specific date and time] someCommand
performs that command or can run an executable at that specific time
chrontab
execute a command regularly
w
prints who is logged on
tload
graphic representation of system load
ps -u accountName | grep programName
get a list of processes from user using a particular program
kill [PID#]
kills a process with that ID #
chmod
u = user g = group o = other
d = directory l = link r = read w = write x = executable
\+ = add a permission - = take away a permission
someCommand > fileName
at the end of a command, redirect the results as text into a file
someCommand»_space; fileName
at the end of a command, redirect the results as text inside and at the END of the file
someCommand 2> fileName
at the end of a command, redirect the error messages into a file
gzip myFile.tar
compresses a file
gunzip myFile.tar.gz
decompresses a file
sudo apt-get install nameOfSoftware
downloads and installs software in a repository
ssh
connects to a remote server
alias
gives a new name to another command
history
all the past commands typed into the shell
rmdir folderName
removes the folder
uniq
strips duplicated lines
locate fileName
searches for file on entire system
hostname
outputs the name of current computer/server
w, finger
see who is logged into this computer
wget someURL
download from a url and save it to current directory
vim
complicated text editor
nano
simple text editor
emacs
complicated text editor
sed ‘s/oldText/newText/’ fileName
replaces all strings old to the new
sed ‘s/old/new/’ file1 > file2
replaces all strings from old to new and makes a new file
echo somethingHere
print function
*
matches any file
Up arrow
repeats previous commands(s)