grep regular expression

grep command

The grep program is a standard UNIX utility that searches through a set of files for an arbitrary text pattern, specified through a regular expression. By default, grep is case-sensitive (use -i to ignore case). By default, grep ignores the context of a string (use -w to match words only). By default, grep shows the lines that match (use -v to show those that don’t match).

Continue Reading

How to execute script automatically after startup with root priviliges

There are 2 ways to do this:

  1. Simply put the commands you want at /etc/rc.local
  2. Put your script in the /etc/init.d directory. After you make the script executable, use the following command to add the symbolic links: Code:
update-rc.d your_script_name defaults

If you ever want to remove the script from the startup sequence, use this: Code:

update-rc.d -f  your_script_name remove

You might want to give a look at the update-rc.d man page for further options you can use with the command.

Continue Reading

Copying Files over the Network with scp

To ”’send”’ file or directory ”’to a remote computer”’:
scp -r [/path/filename] [login name@ip address] :

To ”’retrieve”’ file or directory ”’from a remote computer”’  ”’address in your pc”’:
scp -r [login name@ip address] : [/path/filename]  [/path/filename]

Here are the meaning of scp command options:

-r — recursively copy entire directory
. — current directory


To copy all txt files in the current directory to your home directory on the destination machine:
scp *.txt

To copy txt files to a destination directory. You have to have write permission on the target directory:
scp *.txt

To retrieve files from the other machine back to the one you’re on:
scp*.txt /home/support/Desktop

Continue Reading

How To Delete File Contents In Linux

How To Delete File Contents In Linux

I am sure you know that situation when you need to delete file contents in Linux. Just think about it – you have some log files on your Linux workstation or server, and their size just keeps growing and growing… Sometimes, it’s really necessary to delete the content of the file, but keep the file itself. So… how can you do that?

In Linux, deleting file content while keeping the file is quite easy! Just use the following command from command line:

cat /dev/null > YOURFILENAME

I recommend you to backup the file first, because you never know when something bad can happen

Continue Reading

How to get the IP address using MAC

It happens alot that you have an IP device (ATA, door phone, …) and you don’t know the IP address. One easy way is to use nmap.

run this command (on linux of course):

$ nmap -sP <ip range>

eg: nmap -sP

make sure you run this as root otherwise it will show only ip address without the MAC

you can also save the output into a txt file this way:

eg: nmap -sP

You can also try using scanssh (next post will cover this)

Continue Reading