Linux
Kill several processes
/grepwww.cyberciti.biz/faq/kill-process-in-linux-or-terminate-a-process-in-unix-or-linux-systems/
kill -9 `ps ux | awk âÂÂ/java/ && !/awk/ {print $2}âÂÂ`
Find and remove
Find and remove all files that have (1).jpg in them with confirmation from a user.
find -name *(1).jpg -exec rm -i {} \;
Compress files under Linux
http://www.cyberciti.biz/howto/question/general/compress-file-unix-linux-cheat-sheet.php
tar -zcvf {.tgz-file} {files}
tar -zcvf pics.tar.gz *.jpg *.png
Redirect stdout and stderr to file
http://www.cyberciti.biz/faq/redirecting-stderr-to-stdout/
$ command-name &>file
Shutdown (turn off) computer over SSH
http://www.cyberciti.biz/faq/shutdown-ubuntu-linux-computer/
sudo shutdown -h now
Symbolic link a new app
ln -s ../registration/ registration
Ruby on Bluehost
http://giangnd.wordpress.com/2010/10/25/install-and-use-your-custom-gems-on-bluehost/
In ~/.bashrc:
export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HOME/ruby/gems/bin
Compare files
http://tldp.org/LDP/abs/html/filearchiv.html
cmp $1 $2 &> /dev/null # /dev/null buries the output of the "cmp" command.
# cmp -s $1 $2 has same result ("-s" silent flag to "cmp")
# Thank you Anders Gustavsson for pointing this out.
#
# Also works with 'diff', i.e., diff $1 $2 &> /dev/null
if [ $? -eq 0 ] # Test exit status of "cmp" command.
then
echo "File \\"$1\\" is identical to file \\"$2\\"."
else
echo "File \\"$1\\" differs from file \\"$2\\"."
fi
Add a user on Ubuntu
http://www.howtogeek.com/howto/ubuntu/add-a-user-on-ubuntu-server/
You can use the -d option to set the home directory for the user. The -m option will force useradd to create the home directory. We’ll try creating a user account with those options, and then use the passwd command to set the password for the account. You can alternatively set a password using -p on the useradd command, but I prefer to set the password using passwd.
sudo useradd -d /home/testuser -m testuser
sudo passwd testuser
Skype in Ubuntu 11.10
- http://ubuntuforums.org/archive/index.php/t-1830122.html
- http://www.ubuntubuzz.com/2011/10/fixing-skype-error-in-ubuntu-1110.html
echo foreign-architecture i386 | sudo tee /etc/dpkg/dpkg.cfg.d/multiarch
sudo apt-get install libxss1:i386 libqtcore4:i386 libqt4-dbus:i386
sudo apt-get remove --purge skype
sudo apt-get install skype:i386
ok, here's an interesting twist.... Scribus works when I run it as root with gksudo scribus-ng
I used sudo skype.
SSH login without password
via http://linuxproblem.org/art_9.html
To login from A to B without a password:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
Depending on your version of SSH you might also have to do the following changes:
- Put the public key in .ssh/authorized_keys2
- Change the permissions of .ssh to 700
- Change the permissions of .ssh/authorized_keys2 to 640
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B hostname
B