Basics

Let's try some commands.

Basics

ls

List information about the FILEs (the current directory by default).

u227664@genetic.master01 ~ $ ls -lh /home/mass/
total 104K
lrwxrwxrwx  1 root    root              25 12 sep  2016 ADM -> /gpfs0/home/ifilesets/ADM
drwxrwxr-x  7 root    u005107         8,0K  9 nov  2016 archive
drwxrwx---  4 root    root            1,0K 15 sep 16:53 bulinux
lrwxrwxrwx  1 root    root              25 19 mai 09:01 GAL -> /gpfs0/home/ifilesets/GAL
drwxr-xr-x 28 root    giga - massgpfs  24K 13 sep 15:00 GRD

cd

change directory

pwd

print working directory

find

whereis

passwd

Change password

Access informations per command

The most important thing, from this point, would be these commands.

  • man mycommand : the "manpage" is the whole informations available for a command, whatsoever it would be. By hitting Q you can leave it.
  • mycommand --help : same as the manpage, but with less informations (faster when one know what he needs)

Directory access shortcuts

When we want to navigate to a particular directory or access a specific file, it's handy to keep in mind the following shortcuts.

  • ~ represents our personal /home directory, e.g. cd ~ and cd ~/Documents
  • .. represents the parent directory, i.e. the directory that contains the one we currently are. If we are at /home/test/public and type cd .. it will take us to /home/test/

We can also use the full path to change to a particular directory, e.g. cd /home/test/public/. The Tab button can help us every step of the way to autocomplete the directories.

Operators

Ampersand (& character)

The function of ‘&‘ is to make the command run in background. Just type the command followed with a white space and ‘&‘. You can execute more than one command in the background, in a single go.

Run one command in the background:

u227664@genetic.master01 ~ $ ping ­c5 www.tecmint.com &

Semi-colon (; character)

Pipe (| character)

And (&& characters)

Or (|| characters)

Not (! character)

Command Combination ({} characters)

Precedence (() characters)

Concatenation (\ character)

Input (> character)

Append (>> characters)

(% character)

Variables ($ character)

What to do with commands that return too many results

If we run "ls" on a directory with 1,000 files, or we use "locate *.png" on a disk with lots of png pictures, we will get too many results.

In this case, we can use a pipe with the vertical bar "|" symbol (accessible with "Shift + \" ) and more or less.

With locate *.png | more we will get the results page by page, and we can reveal the next pages by pressing space. We quit by pressing "q".

With locate *.png | less we will still get the first page of results, but navigate up and down with the arrow keys. Again, we quit with "q".

Wildcards

?

Replace any single character. So, if we have two files names test1file and test2file, we can delete them both with "rm test?file". But this won't delete test12file.

*

Replace any string of characters. "rm test*file" will delete test1file, test12file, testBLABLABLAfile. It will also delete any other filename that begins with "test-" and ends in "-file", including testfile.

Files manipulation

echo

Show raw content of a variable.

cat

Concatenate and show file(s) content.

touch

Create an empty file, or change the date of modification (without modifying it's content) of an already existing one.

mkdir

Make directory.

cp

Copy.

mv

Move.

rm

Delete.