Beginner S Linux Cheat Sheets: Bash Vi/Vim

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Beginners Linux Cheat Sheets

Beginners Linux Cheat Sheets


February 2009 - Andrea Minoia

List of topics: This document wants to be a rst aid for new Linux user. A google search will produce a huge number of link to cheat sheets, tutorial, guide and often is difcult to nd that basic command you need. This is not a tutorial nor a guide and is far to be a complete linux user reference. Is just a starting point, something you can use when you are sit in front of your terminal and you have no clue on whats next. I have decided to introduce four topics: bash, vi/vim, gnuplot and queuing systems on remote clusters. This because this collection of basic cheat sheets has been written to help visitors coming in our laboratory for a short staying. In particular for those who are not familiar with linux and computational chemistry. Bash VI/VIM

Beginners Linux Cheat Sheets Bashs basic cheat sheet mkdir - make a directory make dir more / cat / tail - display content le more le cat le tail le tail -n 20 le tail -f le > < | - operators cat le > newle cat le >> newle command < le grep string | more : display content of le bit by bit : display content of le all at once : display last 10 lines of le : display last 20 lines of le : display last 10 lines of le each time le is updated

: create dir in the current dir

cd - change dir cd / cd : go to home dir cd path/of/the/dir/u/want/to/go : move to the specied directory cd .. : go to the parent directory rm - remove rm le rm -r dir rm -f

: delete le : delete directory : delete without asking conrmation

mv - move / rename mv le newle mv le new/path mv le new/path/newle mv -f cp - copy cp le newle cp le new/path cp le new/path/newle cp -f ls - list le ls ls -l ls -a ls /other/path ls le

: redirect output of cat to newle (overwrite if newle exists, otherwise newle is created) : append output of cat to newle : redirect le into a command (e.g. a program) : use the output of grep as input of command more

: rename le in newle : move le in the specied dir : move le as newle in the specied dir : move without conrmation if overwriting

: copy le in newle : copy le in the specied dir : copy le as newle in the specied dir : copy without conrmation if overwriting

? * - wildcards rm -rf * mv le* /new/path rm -f le_00?.com

: remove all les and dirs in the current dir : move all les whose name starts for le in new/path : ? stays for every character in that position

: list content current dir : list content current dir in a detailed way : list hidden les in the current dir : st content of another dir : check if le is present in the current dir

tar / zip / gzip - archives zip/unzip le.zip gzip/gunzip le.gz tar cvf le.tar * tar xvf le.tar tar czvf le.tar.gz (or .tgz)

: create/extract compressed zip archives : create/extract compressed gzip archives : create non-compressed tar archived named le.tar of all the les and dirs in the current dir : extract tar archives : create compressed tar archives (same as gzip le.tar)

Beginners Linux Cheat Sheets tar xzvf le.tar.gz : extract compressed tar archives (same as gunzip le.tar.gz) for /do /done - do something over a loop for f in scan.*; do analyze $f -k le.key e >> anen.out ; done : perform a tinker energy analysis on all les scan.* and append the results in anen.out

ssh / scp - connect to remote server (all commands given from local server) ssh user@server : connect to server (server can be the name or the IP address) ssh -XY user@server : allows export graphical display scp le user@server:/path : copy le from local to remote server scp -r dir user@server:/path : copy dir from local to remote server scp user@server:/path/le . : copy le from remote server to local dir grep - nd a string in les grep string_to_search le : search the string in le grep -R string_to_search * : search the string in all les and directories grep -c string le | nl : search string in le and return the number of lines containing string. The output of grep is suppressed by the ag -c df - disk usage df -m

useful combination of commands commands: cp $(ls | egrep -v ^#) /where/to/copy

: copy all les except those starting with # in the specied location

&, ctrl+z, bg and fg - run in background molden & : start and run molden in background ctrl+z : suspend a running program bg : send in background a suspended program fg : bring in foreground a program running in bg && - and make all && make rename the ctrl+t - ip last two characters typed teh ctrl+t : you get the

: display disk usage in MB

: execute two commands one after other.

sed - stream editor sed 's/day/night/' <old >new paste - paste two le paste le1 le2 > out man - get help man command

: search all words day in le old and replace them with night in the new le new

: paste le1 and le2. Usefule to create multicolumn le by merging two input les. : display help for command

Bash: advanced use The bash shell is not only a place where type commands, but is a powerful and exible environment that allow you to create scripts and programs. Here some examples:

----Return to the list of topics

Beginners Linux Cheat Sheets VI /VIMs cheat sheet vi is a widely used text editor, extremely powerful but usually lack of a graphical interface, which make things a little bit complicate for new user. There are two operating modes in vi: edit mode and command mode. When vi starts, you are in command mode: type i to go in edit mode and start to write. Press the escape key to return in command mode. Please, forget your mouse ;) from command mode you can go to insert mode with: i : start editing from the current position of the cursor a : start editing from the position next to the current position of the cursor shift+a : start editing from the end of the line o : insert a newline below the current line, and start editing shift+o : insert a newline above the current line, and start editing some commands in command mode: x : delete current character n dd : delete n lines starting from (and including) the current one (dd to delete 1line) shift+g : jump to the end of the le n+shift+g : jump to the nth line 1+shift+g : jump to the 1st line ctrl+g : info about le (name, current line, total line, ...) n shift+y : yank n lines starting from (and including) the current one (Y to yank 1 line) p : past yanked or deleted lines below the current line shift+p : past yanked or deleted lines above the current line . : repeat last command or text entry u : undo last command /string : search string in le. type n to jump to the next occurrence, shift+n to jump to the previous occurrence :1,$s/string/string2/ : replace string1 with string2 in all the le :n,ms /string/string2/ : replace string1 with string2 from line n to line m :sp : split horizontally the current vi windows in two :vsp : split vertically the current vi windows in two ctrl+w up/down/left/right : change active window (if window has been split) :e le : open a le /create new le save, quit, open (command mode): :w : write (save) :w! : overwrite an existing le :q : quit :q! : quit without saving :wq : save and quit visual block (command mode) ctrl+v : select part of a le (move with the cursor) and then you can use dd, Y, x, ... Ask google to tell you more about vi, or ask man, or have a look into the doc directory of your crunchvm.

----Return to the list of topics

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy