Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most powerful examples of Unix commands or scripts every programmer should know

People also ask

What is the most powerful command in Linux?

sudo. The sudo command lets users operate applications as a different user, by default the root. If the user uses a lot of time on the prompt then the sudo is one of the commands that users will utilize pretty often. This is the most important command.


I find commandlinefu.com to be an excellent resource for various shell scripting recipes.

Examples

Common

# Run the last command as root
sudo !!

# Rapidly invoke an editor to write a long, complex, or tricky command
ctrl-x ctrl-e

# Execute a command at a given time
echo "ls -l" | at midnight

Esoteric

# output your microphone to a remote computer's speaker
dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

How to exit VI

:wq

Saves the file and ends the misery.

Alternative of ":wq" is ":x" to save and close the vi editor.


  • grep
  • awk
  • sed
  • perl
  • find

A lot of Unix power comes from its ability to manipulate text files and filter data. Of course, you can get all of these commands for Windows. They are just not native in the OS, like they are in Unix.

and the ability to chain commands together with pipes etc. This can create extremely powerful single lines of commands from simple functions.


Your shell is the most powerful tool you have available

  1. being able to write simple loops etc
  2. understanding file globbing (e.g. *.java etc.)
  3. being able to put together commands via pipes, subshells. redirection etc.

Having that level of shell knowledge allows you to do enormous amounts on the command line, without having to record info via temporary text files, copy/paste etc., and to leverage off the huge number of utility programs that permit slicing/dicing of data.

Unix Power Tools will show you so much of this. Every time I open my copy I find something new.