Jump to content

Recommended Posts

Posted

As we all know, Linux OS contains a lot of packages by default desktop installation. They contain thousand commands and when combined, produce more functions. Most of the commands here are issued using the super user root or the super administrator account.

 

First Top 25 Quick Linux Command Line Tips - Part 1

 

1. How to create a return email address from command line when using mutt ?

 

Useful when, as systems administrator, creating email address from command line directly from linux terminal console (LTC).

 

# export REPLYTO=youremailaddress@yourdomain.com

 

2. How to dump a website into your terminal screen ?

 

Useful when trying to retrieve some dynamic text-based data from a website via linux terminal console (LTC) and process those data from server-side scripts like bash shell and/or perl scripts.

 

# elinks -dump "http://www.bbc.com/"

# lynx -dump "http://www.bbc.com/"

# links -dump "http://www.bbc.com/"

 

3. How to dump a website into a file ?

 

Simply redirect the output to a text file. Note that there are server-side scripts that could not be processed by the above commands such as javascripts etc.

 

# elinks -dump "http://www.bbc.com/value.php" > file1.txt

# lynx -dump "http://www.bbc.com/value.php" > file2.txt

# links -dump "http://www.bbc.com/value.php" > file3.txt

 

4. How to sort files containing alpha numeric characters in a file with one command ?

 

Useful when you have sets of files that contains file naming convention patterns. For example, all files with file00 filename.

 

# cat filename101*.txt | sort -n

 

4. How to remove duplicate lines from a file ?

 

Useful when duplicated text lines exist inside a text file.

 

# uniq < filename.txt

 

5. How to force rotate of all your defined log files located in /var/log/ ?

 

Userful if you want to quickly rotate log files manually. Log file rotations can be done automatically though.

 

# logrotate -f /etc/logrotate.conf

 

6. How to change the interval time of your daily and weekly system cron jobs ?

 

# vi /etc/anacrontab

 

7. How to start X / Gnome from terminal ?

 

Useful when troubleshooting Linux X and trying to fix VGA driver issues.

 

# startx

 

8. How to backup your X configuration and start with fresh one?

 

Useful when updating your X configuration.

 

# mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old

# gdmsetup

 

9. Do you have a very old and nice webtool for newbies or junior system admins?

 

Webmin is browser-based server configuration which works mostly with server admins

 

10. How to launch program into background process ?

 

Useful if you want to execute a script and put into background process, that is programs running while you are busy with another one.

 

# program-name &

 

10. How to locate and find file(s) in CLI ?

 

Useful when searching for files. This is alternative for locate command.

 

# find /foldername -name name-of-file

# find /home -name file*.txt

 

 

11. How to know your current shell id, group id, groups your current shell belongs to after successfully entering into a linux box?

 

# id

 

12. How to know who is currently active from ssh connection from your server ?

 

Useful when trying to identify currently connected SSH user

 

# w

 

13. How to know all your opened UDP ports and connections ?

 

Useful when trying to see and monitor opened UDP ports.

 

# ss -u -a

 

14. What are the most commonly known world writeable and readable folders?

 

Userful when trying to backtrace hacked linux box dropped zones. So watch out for any scripts or file changes of those folders!

 

# cd /tmp

# cd /dev/shm

 

15. How to build rpm package from source file (*.src.rpm) ?

 

Userful when building rpm package. Most probably, you'll find the sources in /root/rpmbuild/SOURCES and the RPM file in /root/rpmbuild/RPMS . If not, try /usr/src/redhat/SOURCES and /usr/src/redhat/RPMS

 

# rpmbuild --rebuild *.src.rpm

 

16. How to find all files from a folder that contains this string and do it recursively ?

 

Useful when searching a file content from large sets of human readable text files.

 

# find /home/user/ -exec grep -li myownstring {} \;

 

17. How to find a specific filename and delete it ?

 

Useful when searching for particular file from a folder with large set of files. This can be done recursively.

 

# find / -name specific-filename.txt -exec rm -rf {} \;

 

18. How to trim my temporary files and delete the ones that are more than 1 month old?

 

Useful when freeing up disk space or looking for a file that is x month old.

 

# find /tmp -mtime +31 -exec rm -rf {} \;

 

19. How to know the descriptions, functions, and more info a a linux command ?

 

More commands for helping linux newbies.

Ex.

 

# man elinks

# apropos elinks

# whatis elinks

# info elinks

 

20. How to know from which rpm package does a particular linux library file belongs to ?

 

Useful when back tracing the package owner of library file.

 

Ex. /lib/libcap.so

 

# rpm -qf /lib/libcap.so

 

21. How to find out interesting port of a particular host ?

 

Useful when doing port scan of particular hosts.

 

# nmap host-IP-Address-here

 

22. How to ping one subnet class of IP address or group of IP address ?

 

Useful when doing ping scan inside one broadcast domain. Note that fping package can be installed separately

 

# fping -g 192.168.100.0/27

$ fping -g 192.168.1.1 192.168.1.254

 

23. How to know if a port is open ?

 

Useful when trying to find out if the port is open for connection or is reachable.

 

Example: port 25

 

# telnet IP-address 25

# nc -dz IP-address 25

 

24. How to watch for file and file size changes of one folder live and not by email ?

 

Useful for real time monitoring of file size changes. This command can be applied to any other else.

 

# cd your-folder

# watch ls -la

 

25. How to divide 9999999999999999 by 3 directly from terminal ? How to use a terminal based calculator?

 

Using math via CLI

 

# echo '9999999999999999/3' | bc -l

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.