Professional Documents
Culture Documents
Lesson 02 Using Essential Tools & Cockpit: Linux Commands
Lesson 02 Using Essential Tools & Cockpit: Linux Commands
Class
Type
Materials
Reviewed
Linux Commands
pwd
whoami
ls -l
ip addr show, ip a
free -m
df -h // (disk free, human readable format)
Bash Shell
// Piping
# ps -aux | less
ps -aux | wc
// Redirection
ls > lsfiles
cat lsfiles
whoami > lsfiles
!cat
ls >> lsfiles
ls qwert // error apears since no file with this name
ls qwert 2> erros.txt // redirect errors to the file errors.txt
ls qwert * 2> errors.txt // will print the output without errors, errors will be re
directed to errors.txt
ls qwert * 2> /dev/null // no errors appear
// Environment Variables
env
env | less
LANG=fr_FR.utf-8
ls --help | less // the man page will appear in French!
LANG=en_EN.utf-8 // change it back to English
// Aliases
alias
alias h=history
(Keyboard) (screen)
2> errfile.txt
>> // append
ls -l /etc | wc
ls -l /etc | less
ls -l /etc | grep host
$ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/cl-root
│ xfs rw,relatime,seclabel,a
ttr2,inode64,logbufs=8,logbsize=32k,noquota
├─/sys sysfs sysfs rw,nosuid,nodev,noexe
c,relatime,seclabel
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexe
c,relatime
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexe
c,seclabel,mode=755
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexe
vmlinuz-4.18.0-
32.el8.x86_64
/dev
(devices)
Interface files to
talk to specific HW
devices.
/dev/sda
/dev/null
By addressing a
/dev file, you are
addressing directly
the Kernel.
The kernel uses the major number at open time to dispatch (send) execution to the
appropriate driver.
The minor number is used only by the driver specified by the major number; other
parts of the kernel don’t use it, and merely pass it along to the driver.
It is common for a driver to control several devices (as shown in the listing); the
minor number provides a way for the driver to differentiate among them.
/proc/partitions
paul@RHELv4u4:~$ cat /proc/partitions
The /proc/partitions file contains a major minor #blocks name
table with:
3 0 524288 hda
3 64 734003 hdb
major
8 0 8388608 sda
8 1 104391 sda1
and minor number of partitioned
8 2 8281507 sda2
devices, 8 16 1048576 sdb
8 32 1048576 sdc
their number of blocks 8 48 1048576 sdd
253 0 7176192 dm-0
and the device name in /dev. 253 1 1048576 dm-1
The minor number is a unique
identification of an instance of this
device type. The devices.txt file in the
kernel tree contains a full list of major
and minor numbers.
/etc
Contains configuration files.
cd /etc
cat passwd
cat redhat-releas
// Redhat Enterprise linux 8.0
cat os-release
/usr : Secondary hierarchy for read-only user data; contains the majority of
(multi-)user utilities and applications.
Contains binaries, libraries, documentation, and source-code for second level
programs.
contains binary files for user programs. If you can’t find a user binary
/usr/bin
under /bin , look under /usr/bin . For example: at, awk, cc, less, scp
/usr/localcontains users programs that you install from source. For example,
when you install apache from source, it goes under /usr/local/apache2/usr/src
holds the Linux kernel sources, header-files and documentation.
cat /var/log/messages
less /var/log/messages
man lvcreate
mandb // mandb - create or update the manual page index caches, to rebuil
d the man database
man -k list // search for commands contains the word "list"
apropos list // apropos list
man -k user | wc // word count, wc - print newline, word, and byte counts for each f
ile
man -k user | grep 8 // filter for "8", section "8"
grep // to filter the results
man man // see how man works
man apropos
man mandb
useradd --help
man 7 glob
ls host*
ls ?ost*
ls [hm]ost // start with either h or m
ls [!hm]ost // does NOT start with either h or m
ls script[0-9][0-9]
touch script{0..100} // create range of files
ls script[0-9][0-9]
ls script[0-5][0-9]
ls *[0-9]* // show also the contents of the directories
ls -d *[0-9]* // show only the directories without their contents
2.11 Cockpit
https://192.168.1.7:9090/