All commands in one place help developers to do routine work faster.
Key/Command | Description |
---|---|
cd | Return to Home directory |
cd [folder] |
Change directory e.g.
|
cd / | Root of drive |
cd - | Previous directory |
ls | Short listing |
ls -l | Long listing |
ls -ap | -a Listing incl. hidden files -p. The"\" at the and for folders |
ls -lh | Long listing with Human readable file sizes |
ls -R | Entire content of folder recursively |
sudo [command] | Run command with the security privileges of the superuser (Super User DO) |
open [file] | Opens a file ( as if you double clicked it ) |
top | Displays active processes. Press q to quit |
nano [file] | Opens the file using the nano editor |
vim [file] | vi [file] | Opens the file using the vim editor |
clear | Clear screen |
reset | Resets the terminal display |
Key/Command | Description |
---|---|
[command-a]; [command-b] | Run command A and then B, regardless of success of A |
[command-a] && [command-b] | Run command B if A succeeded |
[command-a] | |
[command-a] & | Run command A in background |
Key/Command | Description |
---|---|
[command-a] | [command-b] |
Run command A and then pass the result to command B e.g Example: ps -ef | grep java |
Key/Command | Description |
---|---|
history n | Shows the stuff typed – add a number to limit the last n items |
Ctrl + r | Interactively search through previously typed commands |
![value] | Execute the last command typed that starts with ‘value’ |
!! | Execute the last command typed |
Key/Command | Description |
---|---|
touch [file] | Create new file |
pwd | Full path to working directory |
. | Current folder, e.g. ls . |
.. | Parent/enclosing directory, e.g. ls .. |
ls -l .. |
Long listing of parent directory |
cd ../../ |
Move 2 levels up |
cat | Concatenate to screen |
rm [file] | Remove a file, e.g. rm data.tmp |
rm -i [file] | Remove with confirmation |
rm -r [dir] | Remove a directory and contents |
rm -f [file] | Force removal without confirmation |
cp [file] [newfile] | Copy file to file |
cp [file] [dir] | Copy file to directory |
mv [file] [new filename] | Move/Rename, e.g. mv file1.ad /tmp |
pbcopy < [file] | Copies file contents to clipboard |
pbpaste | Paste clipboard contents |
pbpaste > [file] | Past clipboard contents into file, pbpaste > paste-test.txt |
Key/Command | Description |
---|---|
mkdir [dir] | Create new directory |
mkdir -p [dir]/[dir] | Create nested directories |
rmdir [dir] | Remove directory ( only operates on empty directories ) |
rm -R [dir] | Remove directory and contents |
[command] | [command] | Allows to combine multiple commands that generate output, e.g. cat data.txt | pbcopy |
less | Output content delivered in screensize chunks |
[command] > [file] | Push output to file, keep in mind it will get overwritten |
[command] >> [file] | Append output to existing file |
[command] < [file] | Tell command to read content from a file |
Key/Command | Description |
---|---|
find [dir] -name [search_pattern] |
Search for files, e.g. sudo find . -print | grep -i '.*[.]xml' |
grep [search_pattern] [file] | Search for all lines that contain the pattern, e.g. grep "Tom" file.txt |
grep -r [search_pattern] [file] |
Recursively search for all lines that do not contain the pattern grep -lr "text to find" * grep this_word this_file.txt |
grep -v [search_pattern] [file] | Search for all lines that do NOT contain the pattern |
Key/Command | Description |
---|---|
[command] -h | Offers help |
[command] —help | Offers help |
info [command] | Offers help |
man [command] | Show the help manual for [command] |
whatis [command] | Gives a one-line description of [command] |
apropos [search-pattern] | Searches for command with keywords in description |
Key/Command | Description |
---|---|
sed replace word / string syntax |
Replace sed -i 's/old-word/new-word/g' *.txt Delete lines containing '#' comment character: initial=( `cat "$startfile" | sed -e '/#/d' | tr -d '\n' |\ # Delete lines containing '#' comment character. sed -e 's/\./\. /g' -e 's/_/_ /g'` ) # Excerpted from life.sh script |
sleep 60s | Wait 60 sec |
container_id=$(sudo docker ps -a -q -f="name=devstack") | Use variable in the bash script |
sudo yum install -y python-pip sudo pip install pyyaml |
Install something: Install python pip |
yum install telnet | Install telnet |
netstat -anp tcp | grep 3000 |
Check who does use the port |