Will Clarke

UNIX Shell For Dummies

2014-10-20

Learning a few UNIX commands can be useful. Since it’s the ‘default’ programming language that pops up when you run the Terminal, it’s worth knowing a few of the more basic commands: These are sorted by ‘difficulty’ - you should know the first ones first.

cd - changes the current directory.

ls - list files or directories in current directory

pwd - print working directory. Shows where you are (relative to the root folder)

Copying

cp - copy

cp -r - copy recursively. Useful for directories.

Deleting

rm - remove

rmdir - remove directory

Moving / Renaming

mv - move

Creating Folders

mkdir - creates a new directory

mkdir -p - creates a series of new directories.

Getting help

man - find the manual

Showing files

cat - show pure text version of the file.

less - outputs text with more features.

sort - guess what this one does…

Comparing files

diff - shows the differences between two files

Finding programs

whereis

Changing File Permissions

chmod

Search for text

grep

I’ve written a quick primer on UNIX file permissions here

Grep’s a fairly big topic:

Grep Book

Flags

Flags are optional parameters that you can pass in to a shell command. We’ve met some already; here’re two: ls -la. You can see a full list of available options under the man page of the commands.


Tags

shell unix bash