More Linux goodness

Here are a list of useful commands to get you up and running – this is not exhaustive.

Command Description
apropos Finds manuals for given keywords and lists commands e.g. apropos sort
info Finds help for a given keyword e.g. info sort
man Displays the manual pages for a given command e.g. man sort
whatis Provides a description of a command (requires full name of the command) e.g. whatis sort
alias Abbreviates a long command e.g. alias ls=’ls –color=auto’
unalias Removes abbreviation
type Displays type and location of a command e.g. type sort
cd Change directory e.g. cd ~
cp Copy files e.g. cp original copiedfile
ln Creates symbolic link/shortcut e.g. ln -s original linkedfile
chmod Changes file mode using [u,g,a] [+,-] [r,w,x] e.g. chmod g+w original
chown Changes file owner. To change user:group to root for a file named original e.g. chown root:root original
ls List files -F, -l, -a are all useful flags
mkdir Make directory e.g. mkdir newdirectory
rmdir Remove directory
mv Move file/rename a file e.g. mv original newdirctory/newfile
rm Remove files
touch Update timestamp of a file or create one if it doesn’t exist. This is useful if a settings file needs to be kept whilst all other files in a directory older than a certain date are to be deleted
find Find files with specific name etc e.g. find ~ -name original
locate Find files recorded in a system database
whereis Find executables e.g. whereis sort
which Finds files in the PATH environment directories e.g. which sort
cat Display or concatenate files
diff Compares the difference between files e.g. diff file1 file2
expand Converts tabs to spaces in a text file
file Returns the file type e.g. file original
grep Powerful way to search for regular expressions
less Displays text file contents
sort Sorts lines in a file
split Splits a file into multiple files e.g. to split a file every 2 lines use ‘split -l 2 original’ and to recombine use ‘cat part.?? > bigfile.tar’
tac Reverses a file, line by line e.g. tac original
tail Show the end lines of a file e.g. tail original
wc Word count for a file returning lines, words, characters e.g. wc -l testfile
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: