Bash command to get you started:
- ssh [email protected]
- grep -lrn PATTERN DIRECTORY/PATH
- export
- ls -al
- mkdir
- rm -rf FILENAME
- less/more/cat
- pwd
- ps -efH
- kill -9
- cp FILE MOVE/TO
- chmod FILE
- chown
- tar/gzip/unzip
- ifconfig
- ping -c 5 IP/URL
- wget URL
- curl
- apt-get/apt/yum/rpm
- find . --name FILENAME
- sort
- wc -l
- free
- head/tail
- df -h
- tree
- alias
- history/!!
vim/emac/nano git,htop,tmux
LS [OPTIONS] [PATH] ls stands for list files and just prints the structure of the directory specified after the command. If you have a Bash command line, you can always press TAB to complete a command or in this case see the folders inside the folder.
Useful Options: -a: Also list hidden files -l: Long detailed list -h: Human Readable
ls -la ~/Desktop
CD [PATH] cd means change directory and switches your active directory to the specified path. At this point you can again press TAB to navigate faster trough your folders. In case you should always use this, as I guess you don’t know your folder structure all the time. On a Mac you can also drag a folder to your terminal to switch to that folder fast!
cd ~/Desktop/my/folder
MKDIR [OPTIONS] [PATH] mkdir stands for make directory at a specified path.
Useful Options: -p: Create parent directories
mkdir ~/Desktop/newFolder
RMDIR [OPTIONS] [PATH] rmdir stands for make directory at a specified path.
rmdir ~/Desktop/newFolder
TOUCH [FILE] With touch you can modify the last modified date of a file or you can create a new file which comes in handy especially for Mac users (which is hardly possible from the finder).
touch new_file.txt
CP [SOURCE] [DESTINATION] With cp you can copy files from one space to another.
cp ~/Desktop/myFile ~/Desktop/aFolder/
MV [SOURCE] [DESTINATION] Similar to cp, mv moves a file to another destination. Move is also often used for renaming files.
mv ~/Desktop/myFile ~/Desktop/myFile_Backup
RM [OPTIONS] [PATH] The mighty remove command has brought pain over many developers. Especially with some options you can cause a lot of trouble, so use this with care if you are a beginner! With this command you can remove everything you want, a lot faster than you would be able inside your finder or whatever. Notice: Files deleted with remove won’t show up in your trash, so handle it with care.
Useful Options: -r: Remove folders recursive (everything inside) -f: Force delete everything without any more questions
rm -r ~/Desktop/aFolder
CAT [OPTIONS] [FILE] This command comes from concatenate but is used most of the time to just print the contents of a file to your screen. In an upcoming tutorial we will see how to write to a file with cat, but for now we just use the basics of the commands.
Useful Options: -n: Print line numbers
cat ~/Desktop/someManual.txt
LESS [OPTIONS] [FILE] less is most of the time better than cat, because you can move through your file/document a lot faster with some commands.
Useful Actions: g / G: Jump to first/last line f / B: Page forward/backward /myWord: Searches for the next occurrence of “myWord”. Jump to next result with n
less ~/Desktop/myDocument.json
PWD Prints the 'present working directory', letting you know where you are in the filesystem.
pwd
HEAD/TAIL [OPTIONS] [FILE] Displays the first/last lines of of a file. 10 lines is the default.
head my/file.txt
tail my/system/log.log
FIND [OPTIONS] [DIRECTORIES]
find . --name myJava.class
GREP [OPTIONS] [DIRECTORIES] When we just want to search and filter out matches
Useful Options: -r: Recursivily look through folders -l: Display the lines where found -n: Display file line numbers -i: Ignore case -A: Show number of line after -B: show number of lines before -v: Exclude matches with this pattern --color: always|never|all --exclude: exclude a file --exclude-dir: exclude a directory
grep
CURL [OPTIONS]
curl
wget [OPTIONS]
wget
LN [OPTIONS] [FILE]
ln
ALIAS VAR=COMMAND
alias gs=git status
SOURCE [FILE]
source ~/.bashrc
CHMOD [OPTIONS] [FILE]
chmod
VIM/EMAC/NANO [OPTIONS] [FILE] Open a text editor
vim filename.txt
emac filename.txt
nano filename.txt
MAN [COMMAND] If you don’t know how to use a command properly, or which possible options exist, look inside the manual of that command! This is a detailed explanation of everything, if you just need a bit help go for --help
Get help with man for the less bash commandShell
man less
less --help
APT-GET/APK/YUM/RPM Package managers are specific to the distro of linux/unix that you are using.