Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

locked by voretaq7 Feb 27 '12 at 22:37

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

comments disabled on deleted / locked posts

54 Answers 54

history - shows last used commands
!<number> - executes the command with that number in history

share
add comment

I'm not sure if I am just displaying my ignorance but I just found out about the "last" command for check who has been logging in. It is very useful.

Another good program is "expect". I makes it extremely easy to automate any ssh/telnet logins or anything that forces you to provide input to a program.

share
show 2 more comments

find <blah> -exec <blah> {} \;

e.g.:

find . -iname *20080[123456].log -a ! -iname *.bz2 -exec bzip2 \{\} \;

share
show 2 more comments

bash history - I normally have 10 or so xterms running. Here is the relavent part of my profile:

# Make history ignore dups, ls, and exit
export HISTIGNORE="&:ls:[bf]g:exit"

# Save 100000 history comamnds
export HISTSIZE=10000

# Make each terminal use a separate history file
HISTDIR=${HOME}/.history
SHELLID=$(tty | sed 's!/!.!g')
HISTFILE=${HISTDIR}/history${SHELLID}

touch ${HISTFILE}

# load last histfile as current history
history -r $(/bin/ls ${HISTDIR}/history${SHELLID} | /usr/bin/tail -n 1)

If I need to search for a command, I can just grep through my history directory.

aespipe - reads from standard input and writes to standard output. It can be used to create and restore encrypted tar or cpio archives.

share
add comment

logger lets you write messages to syslog from the shell prompt or a script.

logger "See? There! It happened again!"
share
show 1 more comment

A post that I have made on Stack Overflow: How to list only subdirectories in the current one?

ls -d */

It's a simple trick, but you wouldn't know how much time I needed to find that one!

share
add comment

Usually people run their desktop system with X. But you can usually access true text-mode terminal, several of them actually. These are called virtual consoles. You can then normally login and use command-line, etc.

Just hit Ctrl + Alt + F1, Ctrl + Alt + F2, etc. Your X-server is generally running at Ctrl + Alt + F7.

This of course is distribution and configuration dependent.

Also this command to kill the X-server is sometimes useful: Ctrl + Alt + Backspace.

These key combinations work at least on i86 PC's.

share
1  
ctrl-alt-backspace is disabled on Ubuntu 9.04 (Code name jaunty). Follow this guide if you want to enable it wiki.ubuntu.com/X/Config/DontZap –  LiraNuna Jun 22 '09 at 9:34
add comment

I find the whereis and which commands handy. Use these when you have alternative versions of the same application with the same name and want to use a specific one of them.

share
add comment
scp

I'm a web dev and our development setup requires me to push files over to our dev server all the time. I wrote a quick wrapper around scp to handle this for me.

share
1  
I don't think that scp is a hidden feature; it's more like the standard way of pushing files from box to box without nfs. –  Kevin M Jun 26 '09 at 15:41
show 1 more comment

The power and flexibility of SSH never cease to amaze me. Also the ability to make a raid array out of anything (floppies, anyone?), all the filesystems available, cool stuff like LVM, the crypto tools, the possibility of crafting your own tools with the myriad of compilers, interpreters, languages... Oh, and not forgetting getting new stuff installed with apt-get or similar.

It is just so much brilliant than windows.

share
add comment
lsof -i - list all opened socket
htop - like top, but with more eye candy
rdiff-backup - for incremental backup
mc - midnight commander 
ethstatus - ethernet statistics
netstat, nmap
iftop - display bandwidth usage on an interface by host
share
add comment

NX combines some of the benefits of screen and ssh -X with clever compression. Now I can run gnumeric remotely over a modem connection and resume it when the connection dies.

share
show 1 more comment

fgrep

e.g. fgrep -r * --include=*.rb

walks the dir structure from the current directory looking for in ruby source files

and is much easier to use than find

share
show 2 more comments

dd - convert and copy files

I use this very frequently to make copys of DVD's or HDD Patitions that I need to backup.

dd if=/dev/sda2 of=/tmp/copy_of_sda2

it's very handy and configurable, just have a look at it's man page

share
add comment

POSIX Capabilities & File POSIX Capabilities

http://www.friedhoff.org/posixfilecaps.html

share
add comment

For "hidden" feature as in most often overlooked or missed by users new to Linux (/Unix).

  • man man
  • man -k <blah> or apropos <blah>

"Hidden" features

share
add comment

My top 5 "hidden" features (hopefully these aren't already up here)

  1. cd - try it out :)
  2. named pipes are not used enough and you can do some really cool stuff with them
  3. system tap, although I'm not great at it and you really need to know your kernel it wields incredible power to the right user.
  4. The combination of piping a list to sort, then to uniq -c and then to sort -n can really work wonders. You can use that to get your top talkers out of an Apache log file or the memory hogs from ps -o.
  5. The proc/sys interface/filesystem. There is so much there that you can adjust/view in real time. Wrapping a cat or grep of statement in watch -d -n 0.1 is awesome and very handy.

Notables are dd, netcat, screen, tcpdump and find but most have been mentioned already.

share
add comment
  • man (gives help on most commands)
  • less (sanely browseable viewing)
  • tail -f (view appended data of a file as it grows)
  • watch (execute a program and view its output periodically full-screen)
share
7  
tail -F is better than -f; it notices if a file is rotated –  niXar May 29 '09 at 9:57
show 5 more comments

I simply can't do without these commands

  • ps -fA (list all running programs
  • lsof (list of open files per process)
  • pushd . (push current directory onto the directory stack)
  • popd . (pop current directory from the directory stack)
  • local account home directory ~/ you can also access a user directory like ~username.
  • replace current bash profile after you've made changes without logging back in. ". ~/.bashrc
  • grep -inR (recursive grep, i = case insensitive, n = show like number, R = recursive)
share
add comment

ctrl + r : searches history for the last command with the letters you specify

share
add comment

Let's see ...

  • I use bash color codes in my /root/.bash_profile to make my root bash prompt a different color than my non-root standard user prompt. Just one more reminder that I'm a single command away from destroying an entire system. ;)

  • I use nc (netcat) a lot to test things. Nice utility with a lot of versatility.

  • For the longest time I never knew that chown could accept both username and groupname together as an argument, i.e.: chown user:group -R /some/directory. That fact has saved me a lot of typing (no more chown/chgrp pairs).

  • The df command's a quick shortcut to see all your mounted filesystems.

  • I use pgrep a lot in scripts to see if a process is running.

  • kexec is pretty neat, lets you reboot without going through BIOS, which shortens reboot times significantly. Don't really reboot a lot, though...

share
show 1 more comment

find is my greatest tool. I use it to locate things, and execute commands on files or directories found.

No system is complete without ssh too.

share
add comment

Never used script(1) to save a terminal session?
apg(1) to make random passwords
do you want to know how many processors/cores you have? nproc(1)
sfdisk(8) great partition tool
multitail(1) multiple tail at once...great tool

share
add comment

For me, the greatest feature is that nothing is really "hidden" - it's all there right under your eyes if you bother to read the documentation or code.

share
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.