Friday, August 3, 2007

50 quick linux command tips part 4

50 quick linux command tips part 4

Again, here are another set of quick and brief linux command sample tips.

1. How to you change file ownership and chown files recursively?

# chown user:user folder -R

2. How to view queued mail in sendmail or postfix?

# mailq

3. How to show which alternative binary program does your machine executes first?

# alternatives --display program-name

4. How to create public/private rsa key pair?

# ssh-keygen

5. How to log out from your current shell ssh connection?

# Ctrl+D
If you are using sudo
# exit ; exit

6. How to load a particular kernel modules?

# modprobe modulename

7. How to remove a module from kernel?

# rmmod modulename

8. How to show all loaded kernel modules?

# lsmod

9. What is the configuration file and configuration directory for modprobe?

# cd modprobe.d
# cat /etc/modprobe.conf
10. How to check if cooling mode of your machine is active?

# cat /proc/acpi/thermal_zone/THRM/cooling_mode

11. How to show thermal temperature of a machine based from acpi?

# cat /proc/acpi/thermal_zone/THRM/temperature

12. Alternatively, how to view a JPG image from command line alternatively?

# jiv filename.jpg

13. How to sort a file in reverse mode?

# sort -r file.txt

14. How to close your current windows in one keystroke?

# Ctrl+F4

15. How to list out all detected HAL devices?

# lshal

16. How to extract files from Microsoft's cabinet archives (.cab)?

# cabextract

17. How do to have two eyes following the mouse from screen?

# xeyes

18. How to lock your screen in Gnome using root?

# yum -y install xlockmore
# xlock -mode swarm -count 1

19. How to probe for the modules needed for your hardware monitoring chips to work?

# sensors-detect

20. How to basically build rpm binary package (.rpm) from spec file?

# rpmbuild --ba specfile
(make sure you have the complete build tools and tar ball package in place)

21. How to follow current growth of a log the same way like tail -f ?

# tailf /dir/log filename

23. How to tail 2 or more file in one shot in a single screen?

# yum -y install multitail
# multitail /var/log/file1 /var/log/file2 /var/log/file3

24. How to make a file immutable?

# chattr +i file1

25. How to suid root a file?

# chmod 4755 file

26. How to manage authentication, firewall, network configuration and system service in single screen interface?

# setup

27. How to check mail for your currently logged in user?

# mail

28. How to cut and paste inside a CLI terminal using the mouse without X?

# service gpm start

29. How to replace / delete a character from a string value?

# cat testfile.txt

# tr 'a' 'Z' < testfile.txt

30. How to create symbolic link of file named linkme?

cd to desired folder where to put the softlink file
# cd /var/www/html
# ln -s /home/myhome/linkme

31. How to create and update new system users in batch mode?

# newusers inputfile.txt
# cat inputfile.txt

31. How to show which system group a user belongs to?

# groups username

32. How to create a new group?

# groupadd newgroupname

33. How to delete an existing group?

# groupdel newgroupname

34. How to delete a user account including user's home folder files and mail spool?

# userdel -r username

35. Alternatively, how to show currently logged in users?

# users

36. How to unmount CD drive?

# umount /dev/cdrom

37. How to add user account in one shot?

# useradd -d /home/user1 user1 -c "User1 User1" -s /bin/false -G groupname -p cryptpassword

38. How to transfer file via ssh?

# scp -C file1 user@remote-host:user-folder-destination

39. How to transfer and syncronize files/folder between two machines?

# rync -avz files1 user@remote-host:user-folder-destination

40. How to add more system path to current PATH values?

# export PATH:$PATH:/your-new-path:/another-path

41. Alternatively, how to print current login name?

# logname

42. How to clear current terminal screen?

# clear
# Ctrl+L

43. How to go to the first character of a long command from CLI terminal?

# Ctrl+A

44. How to turn on all swap file specifed from /etc/fstab?

# swapon -a

45. How to pause between command execution?
Ex. 3 seconds

# sleep 3

46. How to show detailed Perl version?

# perl -V

47. How to show current spamassassin version?

# spamassassin -V

48. How to get the numeric identifier of current host?

# hostid

49. How to list file and directory contents in a tree-like format?

cd to desired folder
# tree

50. How to show quick history of commands by root?

# history

These document entries are not in any way a rehashed or reaped from any other site. It is also not a replacement or correction to any linux commands, blogs, websites, or any linux man pages or whatsoever. I have them here as blog entries to share my own personal linux reference. The decision to use them from any linux boxes is not mine to keep. Use them with care, use at your own risk.

These linux commands are also available from linux man pages for further reading and study.

# man command

That is all. Have a nice day!

Redhat is a registered trademark by RedHat company.


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