UNIX commands
Basic commands
su: login as super user (e.g. root)pwd: current directoryls: list filesls -l: list files with detail infobunzip2 [FILE_NAME]: decompress file at same locationcp [FILE_1] [FILE_2]: copy file1 to a file called file2mv [FILE_1] [FILE_2]: (move) rename file1 to the name file2mv [FILE_1] /[FOLDER_NAME]: move file1 to the [FOLDER_NAME] directoryrm *: deletes everything in a subdirectory (http://cmgm.stanford.edu/classes/unix/rm.html)rm -r *: deletes everything in directoryrm test.txt: removes only file with a name "test.txt" on the endtail -500 FILE_NAME | less: see last 500 lines of filescat [FILE_NAME]: view file
Size
df -k: disk sizedf -g: disk sizedf -h: disk sizedu -s [FOLDER_NAME]: folder size infodu -sh ./: current directory sizedu -sh -- *(D) | sort -k1n: order parent folder by size in ascending orderls -l | grep ^- | sort -nr -k 5: order files as per size
Basic network commands
ifconfig: similar to ipconfig (display network interface parameters)hostname: get machine's name/etc/init.d/network restart: restart network
Install
rpm -ivh: install rpm bin file
Init file
/etc/init.d/chkconfig <SERVICE_NAME> off: off service at startup with super user (http://www.aboutlinux.info/2006/04/enabling-and-disabling-services-during_01.html)/etc/init.d/chkconfig <SERVICE_NAME> on: start service at startup with super user (http://www.aboutlinux.info/2006/04/enabling-and-disabling-services-during_01.html)
Terminal
tty: to check terminalps -ef | grep java: check the java processeskill -9 <process_id>: <process_id> is returned by prev command.
User
startx: start GUIuseradd <user>: create new userpasswd <user>: change password for usergroupadd <groupname>: create new groupusermod -g <groupname> <user>: Assign a user to a primary groupusermod -G <groupname> <user>: Assign a user to secondary groupswho am i: current user
vi Editor
vi [FILE_NAME]: Open or edit a file.Esc: Switch to Command mode.oo / o: insert new line after current lineOO / O: insert new line before curren linei: Switch to Insert mode.[ESC] i ENTER: insert into file to location:w: Save and continue editing:wqorZZ: Save and quit/exit vi:x: to file save:q!: Quit vi and do not save changesyy: Yank (copy) a line of textp: Paste a line of yanked text below the current lineo: Open a new line under the current lineO: Open a new line above the current lineA: Append to the end of the linea: Append after the cursor’s current positionI: Insert text at the beginning of the current lineb: Go to the beginning of the worde: Go to the end of the wordx: Delete a single characterdd: Delete an entire line[X]dd: Delete X number of lines[X]yy: Yank X number of linesG: Go to the last line in a file[X]G: Go to line X in a filegg: Go to the first line in a file:num: Display the current line’s line numberh: Move left one characterl: Move right one characterj: Move down one linek: Move up one line
Set ENV
vi ~/.bash_profile: env variable setup filesource ~/.bash_profile: export env variables to systemexport JAVA_HOME=/root/java/jdk1.7.0_45export MAVEN_HOME=/root/java/apache-maven-3.1.1export ANT_HOME=/root/java/apache-ant-1.9.2export PATH=$PATH:${JAVA_HOME}/bin:${MAVEN_HOME}/bin:${ANT_HOME}/bin
Increase swap size
dd if=/dev/zero of=/.swapfile bs=1M count=2048mkswap -v1 /.swapfileswapon /.swapfile
Miscellaneous
- ubuntu jdk setup: http://www.mkyong.com/java/how-to-install-java-jdk-on-ubuntu-linux/
- clear temp directory: http://forums.opensuse.org/english/get-technical-help-here/how-faq-forums/unreviewed-how-faq/412640-clear-temp-files-boot.html
sync; echo 3 > /proc/sys/vm/drop_caches: clear buffer cache/tmp/VMwareDnD: VM ware DragNDrop files - verify and delete