Commands

switch user

su - root

Switch to the root user. If you enter the password correctly, your prompt will change from a dollar sign to a pound sign

minus sign

Without the minus sign the login profile for the new user is not executed -- so this user environment variables and aliases would not change. As a result the new user personal setup commands (PATH and so on) would not run.

Use the minus sign when you temporarily become another user.

exit

To return to your previous identity.

su - emanuele

Switch to emanuele user.

Open a Gnome window from shell

gnome-open .

Reload the shell

source

Once you have edited your .bashrc file, open a terminal and execute the command to make the bash shell to re-read the contents of the .bashrc file as follows:

 $ source ~/.bashrc 

To reload the .bash_profile without re-login or restart

 $ source .bash_profile

Unzip files

tar
$ tar -zxvf filename.tgz
	$ tar -zxvf filename.tar.gz
	$ tar -jxvf filename.tar.bz2

referece:

UNIX / Linux Decompress tgz / tar.gz Files

Search files

find

Copy all files found to a director

resources: http://www.linuxquestions.org/questions/linux-newbie-8/how-to-tell-bash-to-move-files-to-another-folder-288830/

The curly braces indicate to exec to use the result of the find operation.

find .-name "*.txt" -exec cp '{}' /destination \;

Please note that if /mydir is part of the searchpath of find, you will get error messages (or warnings) from cp (and probably mv) that source and destination are the same file.

How to search and list absolute path

http://stackoverflow.com/questions/246215/how-can-i-list-files-with-their-absolute-path-in-linux

find `pwd` -name .htaccess

How to do a search and replace over multiple files

http://www.liamdelahunty.com/tips/linux_search_and_replace_multiple_files.php (does not work!) find `pwd` -name "*.html" -exec `perl -pi -w -e 's/\.\.\/\.\.\/css\/stylesheet\.css/\.\.\/\.\.\/\.\.\/css\/stylesheet\.css/g;'` '{}';

Create multiple directory

mkdir for((i=1; i<10; i++)); do mkdir dir$i; done PS: `command` is the same as $(command)----those are "backtics", not single quotes.

Kill processes VS kill background jobs

kill
kill -9 $(jobs -p)
kill all background jobs
kill -9 vs kill -15
  • kill - 9 force the process to die

  • kill - 15 ask the process to day (and it can be ignored!)

Global Variable

env
http://www.computerhope.com/unix/uenv.htm
export
Adding a path
Adding a global variable

Printer commands

lsq lsrm
su lprm -

remove all the printing queues

ubuntu.com - lprm manpage
ahinc.com - Linux Printing