Terminal and Command-Line Cheat Sheet: Simon
Terminal and Command-Line Cheat Sheet: Simon
simon
<2018-03-08 Thu>
Contents
1 Getting Help 2
4 Where I am 3
6 Change directory 3
14 Search files 6
1
16 Check what is going on 6
Open a Terminal and you can directly type the stuff below.
If you have time, enjoy this essay by the science-fiction author Neal
Stephenson.
Editing file is most of the job, so please also consider using a descent editor.
The author uses and recommends GNU Emacs, because it simply rocks!
1 Getting Help
man <command>
Quit by pressing q.
man ls
man cd
man mkdir
cd /data/home/alturi/project/long-filename.ext
cd /d[TAB]ata/h[TAB]ome/al[TAB]turi/pro[TAB]ject/lo[TAB]ng-filename.ext
0
This document was generated the: Wednesday 21st March, 2018, 15:42
2
When you type ambiguous character (e.g., pro should point to your fictional
folder project/ or product/), the completion does not work. In that case,
hit TAB twice to view all the possible matches and then type a few more
characters.
history
4 Where I am
pwd
mkdir -p my-project/this/that
6 Change directory
cd <directory>
For example, go to the previous created folder, and verify you are in:
cd my-project/this/that
pwd
cd ..
pwd
3
cd that/
pwd
cd ../..
pwd
Note that:
cd
go to the $HOME folder.
4
10 Clear the terminal window (just cosmetic)
clear
For example, copy the history of the command lines and list the folder:
cp ~/.bash_history ~/my-history
ls -rt1
cp my-history my-project/this/that
ls my[TAB]-project/[TAB]this/[TAB]that/
Copy folders:
cp -R my-project my-project2
ls -R my-project2
5
14 Search files
find <dir> -name "<filename>" -type f
For example, list all the files with the extensions .fastq.gz in the current
folder:
find . -name "*.fastq.gz" -type f -print
Find all Pearl files .pl containing the occurence xls and print the line:
find . -type f -name "*.pl" -print | xargs grep -nH xls