Unix commands

DNS lookupEver wondered who is behind a domain name? Dig might help you:


yum og rpm

Easy install packages on Linux with yum and rpm.


Find what packages are ready for updating:

List out the whole rpm database, and find those who have something with php:


Did you loose your shell, you said!? Do you need more shell sessions?

Here is the scenario: you are logged into a server over a crappy internet link. You do some advanced stuff, and in the middle of a very important job, you loose the connection, and everything is lost!

Ach ja! and then you can start all over again.

Well, with ‘screen’ you can avoid this. Don’t loose your work anymore and use ‘screen’!

Some reading material:

Short version here. Start screen with:

Open a new windows (shell) in screen:

Go back and forward from window to window:

(n=next, p=previous)



Find a screen session:

Reconnect to existing screen session:

sed commando

If you need to replace words or characters in files, use sed!

  • where “/” is the chosen separator sign
  • where “word” is the word we like to replace, and “replacment” is the new word.
  • index.htm is the file that contains the text

Example with other separator characters:

This will change c:\windows\sys32 to /mnt/drive_c/windows/sys32

find commando

Have thousands of files on your linux server? Find is the most powerful tool you can ever use on a Linux server!

If you like to find all files with extension .htm:

You can then add the -exec option to do some more interesting stuff.


“Find all files from / where file extension is .htm and then run ‘ls -al’:

The command:

“Find all files from /var/www/html where the word ‘password’ is present.”

Unix/Linux command:

Find all lines with ServerName or ServerAlias

Some times you like to go through all the configuration files in Apache to find registered servernames and serveraliases. You can do this with this command:

which is doing something like:

Find all files in /etc/httpd with the name ‘something.conf’, print out (cat) the content of these files to your screen, then grab all lines with ‘servername’ or ‘serveralias’, not case-sensitiv, remove all lines that start with a ‘#’, then remove all empty lines. At the end, remove dublicate lines.

Search for words in PDF files:

If you have 100 pdf files, and you want to find which files contains a specific word, for instance: “technologies”, you can do that with this command:

The comand lists alle the filenames, and under the lines which contains the requested word.

find and sed together

If you have X number of files, in several folder, and you need to replace on word with another, you can do this with:


Leave a Reply

Your email address will not be published. Required fields are marked *