Linux tips for newbies

1) Dont remember the command
#apropos "list directory"

2) use tab to complete the type, dont type all the words

3) to goto last dir
#cd -

4) to goto home dir
#cd ~

5) want to find that file
#locate filename

6) for tips on VI editor, see VI post

7) report file system disk space usage
#df -kh

8) to get/set hard disk parameters
#hdparm -t /dev/sda5
replace /dev/sda5 with the name of your disk

9) Use seq command to generate sequences
# seq 1 5
output will be
1
2
3
4
5
This you can use in many places including scripts, eg
# for i in `seq 1 5`; do echo "i is $i" ; done
output will be
i is 1
i is 2
i is 3
i is 4
i is 5

10) Sending mail through linux command line
First check, whether sendmail is running

#/etc/init.d/sendmail status
if not run it via (you need to be root for this)
#/etc/init.d/sendmail start

then, send mails using either mail or mutt command as below:

# echo "body of the mail" | mail -s "subject of the mail" toAddress
Give recipient's mail id in place of toAddress

As for body of the mail, you can also redirect from a file, like
# mail -s "subject of the mail" toaddress < body_mail.txt

if you want to send file as attachment, you can use mutt instead
# echo "body of the mail" | mutt -s "subject of the mail" -a fileToAttach.txt toAddress
Give recipient's mail id in place of toAddress

No comments:

Books I like

  • Inside C++ Object Model
  • Unix Network Programming - Stevens
  • Professional-c++-programmer-to-programmer - wrox
  • Beautiful-code-leading-programmers-explain-how-they-think-theory-in-practice