Linux
Find mac address in linux machine
# ifconfig | awk '/^eth0/'
the above command will print the Mac address as
OUTPUT:
eth0 Link encap:Ethernet HWaddr 00:12:B1:57:AB:52
Command to get the mac address of a machine
# ifconfig | awk '/^eth0/ {print $5}'
OUTPUT:
00:12:B1:57:AB:52
..
Crack rar 7z zip file password in Linux
If you forget your password for compressed archive (rar, 7z, zip), RarCrack is the solution. RarCrack uses a brute-force algorithm to find correct password. You can specify which characters will be used in password generations.
Preparing your system for installation
Install the following package
# aptitude install libxml2-dev build-essential
Download the latest version of ..
Add tweer from command line
Update twitter using curl
This function will update your tweet from command line
tweet(){ [ ${#1} -lt 141 ] &&
curl -su user:pass -d source=curl -d status="$1" http://twitter.com/statuses/update.xml >/dev/null || echo $(( ${#1} - 140 )) too many characters >&2; }
This one is long, but includes error checking and will let you ..
Find files used by a user in a folder
View user activity per directory.
lsof -u someuser -a +D ./
View all files opened by a user in specified directory.
The +D option makes lsof search all sub-directories to complete depth, while ignoring symbolic links.
OUTPUT:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF ..
Find and delete thunderbird's msf file
Find and delete thunderbird's msf files to make your profile work quickly again.
find ~/.thunderbird/*.default/ -name *.msf -exec rm -f {} \;
Find command will find the msf file from the specified home directory or location and the exec command will remove the file found by using find command.
..
Find alive systems in network
nmap Command to list the system on network connection
nmap -sP 192.168.1.0/24
OUTPUT:
Starting Nmap 4.68 ( http://nmap.org ) at 2010-06-06 20:38 IST
Host w3calculator.com (192.168.1.1) appears to be up.
Host w3calculator.com (192.168.1.2) appears to be up.
Nmap done: 256 IP addresses (2 hosts up) scanned in 1.144 seconds
The nmap command will list number of host ..
Command to create temp file or directory
Linux Command to create temp file
tempfile=$(/bin/mktemp)
Linux Command to create temp directory
tempdir=$(/bin/mktemp -d)
..
Display off valid users on the workstation
If you dislike Fedora's default behaviour of showing all the valid users on the workstation during a X-windows login this will make the user type a userid and password.
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/gdm/simple-greeter/disable_user_list true
..
Debian linux version
Find a Package Version on Debian based distribution
dpkg-query -W -f='${Version}\n' package-name
The command will query the package list of debian packages and will list the distribution.
..
List files with modified time
find . -type f | xargs ls -ltrhg
find and list normal files and list them sorting with modification time without group
l: with detailed information
t: sort with modification time
r: reverse order
h: show file's size in human-readable format,
such as K(kilobytes), M(megabyes) etc.
g: do not show group
..
Display which distro is installed
How to find linux distribution installed on your machine?
cat /etc/*release
Output
Fedora release 10 (Cambridge)
Fedora release 10 (Cambridge)
Fedora release 10 (Cambridge)
This command works in all all linux distros. ..
Print a file as seen in mirror
How do I print a file in reverse order?
tac -r -s "." FILENAME
Example:
Lets consider a file print_reverse.sh
cat print_reverse.sh
for x in $(grep -r "isam" test)
do
echo $x
done
tac -r -s "." print_reverse.sh
eno
dx$ ohc
eo
d)tset "masi" r- perg($ ni x ro
..
Tail a file at one line per second
tail -fs 1 somefile
The -s option allows you to specify the update interval
tail -f somefile | while read line ;
do echo $line ; sleep 1; done
Tail a file at one line per second. The sleep value 1 in this case controls the update speed of tail -f.
..
Yum command to list packages
yum list available
This command will list all the available packages in yum repository
How to list just one repo with yum. First I disable all repo, second I enable just the repo that I want to list.
yum --disablerepo=* --enablerepo=epel list available
..
Diaplay memory usage
Find memory usage of a particular process or command by a user
ps -o comm,%mem,args -u nobody
output:
proftpd 0.2 proftpd: (accepting connections)
mysqld 1.0 /opt/lampp/sbin/mysqld --basedir=/opt/lampp....
httpd ..