30+ useful Linux commands list
Follow @ggarronThis collection of commands are some of the commands I have learned in these years. Of course I am not the author of them, as no one is the author of any command in Linux. I have found some of them in differente pages, and modify some of them, others I have "created" by myself. Reading books, or man pages.
Disclaimer: Try any of these commands, in non-production servers, some of them may break something
Add yours in the comments.
Purge configuration files of Debian's removed packages
There are different ways to do this, these are some options.
Create movies from jpg files
Empty (erase contents) of a file
Once again there are different ways to do this:
Find duplicate files, based on size and MD5
Replace space on file names with underscores
Convert a man page to txt file
List the most used commands in your history
Execute a command, and do not save it in history
Attach a clock to the command line prompt
Force file system check
Create and mount a RAM disk
Call commands from History
You may call command from history by numbers:
Count lines and words in a text document
Mount a remote file system via ssh
Copy ssh public key to a server to access it with no ssh password
Generate random passwords
Update Twitter from the command line
Replace words in a document using sed
List type of network connections active and the number of them
Mount an iso image as disk
Reset the terminal, when it get screwed, and you can only see garbage on it
List all processes with stablished connections
Backup a disk or partition to an image
Simple HTTP server to share files
Change the layout of you keyboard on the fly
Read a compressed file on the fly, without uncompressing it
Use lynx to store web pages as text
Determining the type of file
make commands keep running after leaving a terminal session or ssh session
Recreate fluxbox menu
sudo aptitude purge '~c'
sudo dpkg -l | awk '/^rc/ {print $2}' | xargs dpkg -P
mencoder "mf://*.jpg" -mf fps=10 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800
:> file
truncate -s0 file
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
#!/bin/bash
ls | while read -r FILE
do
mv -v "$FILE" `echo $FILE | tr ' ' '_' `
done
man cp | col -b > /tmp/man-cp.txt
change cp for any command you want to have its man page in text format.history | awk '{print $2}' | sort | uniq -c | sort -rn | head
<space>command
You need to configurehistory to work that way, by setting ignore space
More info here
export PS1="${PS1%\\\$*}"' \t \$ '
The output will look like this:[ggarron@arch ~] 16:13:14 $
sudo touch /forcefsck
orsudo shutdown -rF now
mount -t tmpfs tmpfs /mnt -o size=1024m
That will create a 1 Gig RAM disk, that you can use to have fast access to files there, just remember is a RAM disk, and all its contents will be deleted when the system is rebooted.history
963 du -h 964 ls 965 df 966 htop 967 df -h 968 df -h 969 historyThen using the number call a command:
!963
Or call it by using the first letters:!df
This last method, is somehow dangerous, as you do not know what arguments and options the command is going to use, so, you can pause it. Using this way is safer:!df:p
It shows you the command but do not run, it, then, you can run it without the :p and it will run, but this time you know the options.wc -l -w mytextfile.txt
sshfs remote-user@remote.server:/remote/directory /mnt/remote-fs/
More info: herecat ~/.ssh/id_rsa.pub | ssh user@remote.machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
More info: heredd if=/dev/urandom bs=16 count=1 2>/dev/null | base64
With 16 characters, if you want only 8.dd if=/dev/urandom bs=8 count=1 2>/dev/null | base64
curl --basic --user "user:pass" --data-ascii "status=Arriving the office" "http://twitter.com/statuses/update.json"
sed -i 's/OLD/NEW/g' FILE
More info herenetstat -ant | awk '{print $NF}' | grep -vE '[:upper:]'| sort | uniq -c | sort -rn
Output:
35 TIME_WAIT
27 ESTABLISHED
2 LISTEN
2 CLOSE_WAIT
mount -t iso9660 -o loop file.iso /media/disk
reset
lsof -i -n | grep ESTABLISHED
More info heredd if=/dev/sda of=~/backup-disk-YY-MM-DD.img
More info herepython -m SimpleHTTPServer
setxkbmap -layout us
zcat file.gz
lynx -dump http://www.go2linux.org > $HOME/go2linux.txt
file *
nohup nice -n 4 [command] > output.txt &
More info herefluxbox-generate_menu