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 FilesSearch files
find
Copy all files found to a director
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
- http://www.linuxquestions.org/questions/linux-newbie-8/kill-all-background-jobs-227978/
- http://www.thegeekstuff.com/2010/05/unix-background-job/
- http://www.thegeekstuff.com/2009/12/4-ways-to-kill-a-process-kill-killall-pkill-xkill/
- 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
Printer commands
- lsq lsrm
-
su lprm -
remove all the printing queues
- ubuntu.com - lprm manpage
- ahinc.com - Linux Printing