Monday, February 16, 2009

Useful Unix Commands for beginners

(1) Copy directory:
cp -r <source_dir_path> <dest_dir_path>

(2) To recursively change file permissions for the entire directory:
chmod -R 777 <dir_name>

(3) To send contents of a text file as mail:
mail mail.id@domain.com < /tmp/file.txt

(4) To change your account Password:
passwd <yourUserName>

(5) To set an Environment Variable:

export VAR_NAME='value'
Examples:
  • export ANT_HOME='/export/opt/apache-ant-1.7.1'
  • export PATH=${ANT_HOME}/bin:${PATH}

(6) Secure copy a directory from one machine to another:
scp -r userName@hostname.com:<srcdir_path>/* <destdir_path>

(7) Viewing installed programs in Unix:
rpm -q [package_name] : shows if the package named 'package_name' is installed
rpm -qa : shows all the installed packages



(8) Installing & Uninstalling programs in Unix
rpm -i /filename.rpm : to install a package
rpm -e [package_name] : to uninstall package named 'package_name'




The list will keep growing.. :)

No comments: