Linux commands

Usefull Linux commands :

Linux version :

cat /etc/*release
more /etc/*release

CPU infos :

cat /proc/cpuinfo
dmesg -h
dmesg | more

Specific directories :

/etc -> General configuration files
/opt -> Additionnal non system libraries
/srv -> Servers : www, nfs, ftp, smaba

Directory stack :

pushd -> Push a directory on the top of the stack (pushd /etc/...)
popd -> Get the last pushed directory from the stack

Finding files and contents :

Will find in « /etc » files with name like « *.service » and adding the string « -devoxx » to the basename of the file :

find /etc -name "*.service" -exec basename {}-devoxx \;

Will find all files in the « /etc » path having the word « system » in it :

grep -rnw /etc -e 'system'

Locate command will find files but in a database where files are indexed. Finding will be faster (find files with « bluetooth » in the name) :

locate bluetooth

Update the ‘locate’ database :


System processes :

ctrl + Alt + F1 – F6 : Changes the tty (bus)

List all the the tty :

ps aux | grep tty

stty -> Current tty configuration.

Pseudo tty slave :

ps -aux | grep sty

Permissions :

Permissions are written in the following order : user owner / group owner / others

File informations :

stat /etc/hosts

The first character tells if it’s a file or a directory (File = « -« , Directory = « d »)
(4 == 001 in binary)

List all the connected users :


List all the connected users with the associated tty (pts/0 is the X Server) :


/etc/passwd -> This file contains all the user passwords and the corresponding shell.

Commands help :

Man command help (You can use the man as in VI. The commands are the same for search…) :

man man

Man command for any shell commands (Java in this example) :

man java

Lists all the commands having the name like the search string :

apropos java

Shows the path of my binary :

which java

Follows a symlink :

readlink /bin/java

Network :

List the active internet connections :

netstat -taupe

Call a specific server, see if he is responding :


Follows a specific server through the network :


Hard disks and mount :

Disk usage in MB on the current partition :

du -hsBM .

Disk usage in MB on a spectific partition ordered by weight :

du -hsBM /var | sort -n

Disk usage and free space for all the system (sorted) :

df -h | sort

List all partitions of a specific drive :

fdisk -l /dev/sda

LVM Local Volume Manager :

Creation of Volume Group (vg0) and mount logical devices inside.
To increase the disk space you can add a physical disk in the Volume Group and then resize the logical disks.

Creation of 3 physical disks :

pvcreate /dev/sdb1 /dev/sdb1 /dev/sdb3

List the physical disks :


Create a Volume Group with 2 disks :

vgcreate vg1 /dev/sdb1 /dev/sdb2

List the Volume Groups :


Create a logical disk in the volume group (size : 150 Mo) :

lgcreate -l 150M vg1 -n lv1

List the Volume Groups :


Create a specific file system (Ext4 or other) :

mkfs.ext4 /dev/sdb1
mount ...

Extending an existing volume group :

vgextend vg1 /dev/sdd3

Resize a logical drive (100 Mo) :

lvresize -l 100M /dev/vg1/lv1

Remove a logical drive :

lvremove /dev/vg1/lv1

Remove a volume group :

vgremove /dev/vg1

Remove a physical disk :

pvremove /dev/sdb1

Boot options :

Add parameters to the bootloader :

boot grub + <e>

Load kernel modules :

modeprobe <MODULE_NAME>

Unload kernel modules :

modeprobe -r <MODULE_NAME>

Run level :

0 : Halt
1 : Single User
2-5 : Multiuser
6 : Reboot

Example : /etc/rc.0 -> script launched while shutdown

Systemd & systemctl :

Service status :

systemctl status httpd

Start a service :

systemctl start httpd

Recursively show control group contents (control group ls) :


Service tree view (can be exported as image) :


Packaging :


Installation and dependencies :


History of shell commands :

History of user commands :


Search in command history : ctrl + r (Up arrow to show items).

Launch the last command beginning with a string :


Other stuff :

/dev/null -> Redirection to nothing.



Une réflexion au sujet de « Linux commands »

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )


Connexion à %s