Linux – program return code.

Written by kisa

On May 17, 2020

And , or , does not matter…

Return code of a given program is 0 if everything went OK and Not Zero if something went south.

logical and &&

$ls -l someFileOrDir && echo OK

logical or ||

$ls -l  nonExistedFile || echo ERR

whenever a program returns Zero a command stops executing, In every other case bash will continue to execute the rest of the line.

does not matter ;

in any case continue the execution:

$ls -lia ; echo hello ; mkdir new_dir

By adding ; between commands we can concatenate multiple instruction in one line without considering the return code of any given part of the instruction.


 Mounting

Static file system information (such as file system/mount point/type/options/dump/pass) are located in

/etc/fstab

to check UID use

$lsblk -o UUID

or

$grep UUID /etc/fstab

$lsblk -o UUID /dev/vda1

To check free space, total space and other drive info use

$df -h

(diskfree)

to see even more information use 

$mount

you can use (slink) at

$ls -l /etc/mtab

that points at 

$ls -l /proc/self/mounts

and another (slink) that points to self/mounts

$ls -l /proc/mounts

All commands above are “unlocked” to all linux users.

But to mount a disk you must be with root privileges. To connect/mount a disk to a catologe use:

$sudo mount /dev/sda /mnt

(what to mount, where to)

for avoiding “sudo” retyping use:

$sudo -i

Unmounting

You can choose either the devie you want to unmount or “from where” you want to disconect it

from where:

$umount /mnt/

or by name 

$umount /dev/sda

 

 

 

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *