FAQ - ba$h0

Frequently asked questions

I’m lost in the terminal

command result
→ or ← Use the arrows to change the prompt position
↑ or ↓ Navigate in the commands you already wrote
ctrl + r Search in the history of commands
history Print to the screen the last x command lines

Frequent error messages:

Generally, the errors in the terminal are clear and helpful. If you don’t understand them:

⮕ No such file or directory

my.name@cluster-i2bc:~$ ls coursBash
ls: cannot access 'coursBash': No such file or directory

Here ls can’t find any directory or file with this name :

⮕ Unrecognized option

my.name@cluster-i2bc:~$ ls --alls
ls: unrecognized option '--alls'
Try 'ls --help' for more information.

⮕ Command not found

my.name@cluster-i2bc:~$ ls-l
-bash: ls-l: command not found

The bash terminal is looking for the command ls-l that it can’t find:

⮕ Permission denied

my.name@cluster-i2bc:~$ rm diff-counts.tsv.gz
rm: remove write-protected regular file 'diff-counts.tsv.gz'? y
rm: cannot remove 'diff-counts.tsv.gz': Permission denied

I want to remove a file but bash is not allowing me to do this:

⮕ Know if a command ended correctly

I want to know if my command ended correctly, is that possible? Yes with $?

my.name@cluster-i2bc:~$ ls -l
total 116
-rw-r--r-- 1 root root 14932 Jan 18  2018 diff-counts.tsv.gz
my.name@cluster-i2bc:~$ echo $?
0
my.name@cluster-i2bc:~$ ls-l
-bash: ls-l: command not found
my.name@cluster-i2bc:~$ echo $?
127

When the command executes correctly, bash returns an error value of 0 (=no error), but when an error occurs the value is different from 0 (in the exemple, the value is 127).

~ or | on MAC

~ = option + N or Alt + N

| = Alt + Shift + L