November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

tcpdump

Tcpdump is a really great tool for network security analyst; you can dump packets that flow within your networks into file for further analysis. With some filters you can capture only the interested packets, which it reduce the size of saved dump and further reduce loading and processing time of packets analysis.

Lets start with […]

Bash Shortcuts and Tips

Bash Shortcuts and Tips

Repeating an argument You can repeat the last argument of the previous command in multiple ways. Have a look at this example:

$ mkdir /path/to/dir $ cd !$

The second command might look a little strange, but it will just cd to /path/to/dir.

Some keyboard shortcuts for editing

There are some […]

Creating large empty files in Linux / UNIX

Creating large empty files in Linux / UNIX

To create large empty files in Linux or UNIX:

# dd if=/dev/zero of=filename bs=1024 count=desired

Example to create a 1GB file: dd if=/dev/zero of=file_1GB bs=1024 count=1000 /or/ dd if=/dev/zero of=file_1GB bs=4096 count=250 /or/ dd if=/dev/zero of=file_1GB bs=2048 count=500

Example to create a 2GB file:

dd if=/dev/zero […]

rsync

rsync examples from command line.

 

To copy all the files in /home/lokams/* of remote host to local directory /backup/home/lokams/ # rsync -e ssh -avz –delete –exclude dir/* –delete-excluded –stats user@remotehost:/home/lokams/ /backup/home/lokams/

To copy the directory /home/lokams of remote host to local directory /backup/home. Directory “lokams” will get created in /backup/home. # rsync -e ssh […]

My Loveable Linux Commands

My Loveable Linux Commands Command Description

apropos whatis Show commands pertinent to string See also threadsafe man -t ascii | ps2pdf – > asciipdf make a pdf of a manual page which command Show full path name of command time command See how long a command takes time cat Start stopwatch Ctrl-d to stop See […]

Find Command

Find Command

Some examples:

Find all files with 777 permissions: find . -type f -perm 777 -print

Find all files that are older than 14 days and ls: find . -type f -mtime +14 -exec ls -l {} \;

Find all your writable files and list them: find . -perm -0777 -type f -ls

Find […]

Multicast on linux

Multicast on linux

 

# setup the routes ip route add 224.0.0.0/4 dev eth0 # try to ping the multicast aware hosts on your lan with 2 pings ping -c 2 224.0.0.1 # 100% packet loss # stop ignoring broadcasts sudo echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts # try to ping the multicast aware hosts on your […]

Comfortable environment On Linux Shell

Comfortable environment On Linux Shell

After installing new Linux or Unix system I like to edit /etc/profile or $HOME/.bash_profile and add following lines:

alias vi=”vim -o” alias ll=”ls -l” alias la=”ls -la” export EDITOR=vi First line is to use vim instead of vi. Second and third lines will create two aliases for ls -l and […]

List number of file handles (open files) for each process

List number of file handles (open files) for each process

Here is a simple script that will show you a number of file handles (open files) used by each process on your Linux system:

ps -e|grep -v TTY|awk {‘print “echo -n \”Process: “$4″\tPID: “$1″\tNumber of FH: \”; lsof -p “$1″|wc -l”‘} > out; . ./out

[…]

Find directory with biggest number of files / directories

Find directory with biggest number of files / directories

Today we had a problem related with a number of files in a directory. We needed to find directories with a biggest number of files / directories in it. Here is a small shell script that will list directories and a number of files/directories in each […]