Saturday, July 28, 2007

50 quick linux command tips part 3

I am writing this document again (part 3) specially for linux newbies audience, even for intermediate users that might think a few of these tricks are useful for them.

Here goes 50 quick linux command tips and tricks part 3.

As root

1. How to have a stop watch scenario from command line terminal?

# time cat

Press Ctrl+C

2. How to measure the time of executing any executable command?

# time firefox

wait 5 seconds and close the application

3. How to CD to a user's home directory?

# cd ~userhome

4. How to CD back to home folder of a currently logged in user?

# cd

5. How to CD back to previous directory?

# cd -

6. How to show all active host IP address?

# ip address

7. How to list out all your iptables rules?

# iptables -L

8. How to save your currently loaded firewall iptable rules?

# iptables-save

9. How to download a file using wget?

# wget -c "http://website.com/file.rpm"

10. How to limit your download rate with wget?

# wget --limit-rate=30k "http://vertito.com/file.rpm"

11. How to download multiple files in one shot?

# wget -c "ftp://vertito.org/file[1-9].iso

12. How to find windows machine with shared folders?

# findsmb

13. How to look for windows netbios name?

# nmblookup -A windows-ip-address

14. How to browse for computers like network neighborhood does?

# smbtree

15. How list folder shared by a particular windows machine?

# smbclient -L windows-machine

16. How to diplay calendar without X?

# cal
# cal -3

17. How to list out all harddisk partition?

# cat /proc/partitions
# fdisk -l

18. How to list out all mounted and labeled harddisk partition?

# mount -l

19. How to show host reboot history?

# last reboot

20. How to get CPU info?

# cat /proc/cpuinfo

21. How to show all interrupts?

# cat /proc/interrupts

22. How to show last successful login users?

# lastlog

23. How to search for a yet unknown package from web repo?

# yum search *packagemaybe*
# yum whatprovides packagemaybe

24. How to setup a shell with yum?

# yum shell

25. How to use yum locally?

# yum localinstall packagename

26. How to find file with 750 file permission?

# find / -type f -perm 750

27. How to find all files not owned by any user?

# find / -nouser

28. How to find all files owned by a user?

# find /home -user vertito

29. How to find files by group name?

# find /home -group vertito

30. How to change timestamp of a file?

# touch -c -t 0707280337 testfile.txt
(YYMMDDhhmm)

31. How to change ownership of a file?

# chown user1:user1 testfile.txt

32. How to set user password details and expiration?

# chage username

33. How to change default home directory of a user?

# usermod -d /new-default-directory username

34. How to change a user finger information?

# chfn username

35. How to change a user shell information?

# chsh username

36. How to change file mode bits?

# chmod testfile.txt

37. How to change and update (multiple) user passwords in batch mode?

# chpasswd

38. How to make an ISO image from contents of a directory?

# mkisofs -V label-name -r directory-name > iso-image.iso

39. How to make an ISO image from contents of a directory and zip it in one shot?

# mkisofs -V label-name -r directory-name | gzip > iso-image.iso.gz

40. Oh, how to eject a DVD/CD disk from a mounted DVD/CD drive?

# eject

41. How to clear or erase all data from a mounted DVDRW / CDRW disk?

# cdrecord -v dev=/dev/cdrom blank=fast

42. How to add an ext3 journal to a filesystem ?

# tune2fs -j /dev/sdb1

43. How to create ext2/ext3 filesystem with bad block checking?

# mkfs.ext3 -c /dev/sdb1
# mkfs.ext2 -c /dev/sdb1

44. How to combine and sort multiple raw files in one shot?

# sort file1 file2 | uniq > newfile

45. How to compare two text files?

# diff file1 file2

46. How to get more memory information?

# cat /proc/meminfo

47. How to get the maximum number of threads of your host?

# cat /proc/sys/kernel/threads-max

48. How to get the file properties of a file or folder?

# stat testfile.txt
# stat foldername

49. How to backup harddisk to another host via ssh?

# dd bs=1M if=/dev/sda | gzip | ssh username@remote-ip-address 'dd of=hda.gz'

50. How to run a command as another user?

# runuser another-user script-name-or-program

That's all.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy