dirname /etc/fstab /etc dirname /usr/bin/ /usr
dirname /path/to/myFile /path/to dirname works/with/a/relative/path/too works/with/a/relative/path
echo /path/to/myFile | dirname
dirname: missing operand
Try 'dirname --help' for more information.
workaround :
echo -e '/a/b/c\n/d/e/f' | xargs -I {} dirname {}
/a/b
/d/e
source : help disown
deborphan is not a Bash command, but a Debian-specific utility. It can be installed via the deborphan package.
deborphan looks for orphaned packages, that is packages which are not required by any other package upon your system.
Flag | Usage |
---|---|
(none) | only list packages which are in the libraries section of the Debian archive, as these are the most likely candidates for removal |
-s --show-section | show the sections the packages are in |
-z --show-size | show the installed size in KiB of the listed packages |
--guess-data | show library (default) + data orphaned packages |
--guess-all | show all orphaned packages |
libssl1.0.0 libgnome2-bin liblognorm1 libpsl0 libprocps3 libboost-iostreams1.55.0
111 main/net libxtables10 183 main/python python3-cffi-backend 352 main/java libservlet2.5-java 53 main/perl libclass-isa-perl 458 main/admin software-properties-common
dmesg's main usage is to display messages from the kernel ring buffer. It lists events in the form :
[timestamp] message
where timestamp is the number of seconds.nanoseconds since the system booted.
Information reported by dmesg is also available in /var/log/kern.log
The kernel ring buffer is a memory area containing kernel messages. It's a fixed-size FIFO area.
Flag | Usage |
---|---|
-c --read-clear | print all messages then clear the buffer |
-T --ctime | Print human-readable Timestamps
Be aware that the timestamp could be inaccurate!
|
-w --follow | wait for new messages |
-W --follow-new | Wait and print only new messages |
Flag | Usage |
---|---|
-a myVariable | declare myVariable is an indexed array (example) |
-A myVariable | declare myVariable is an associative array (example) |
-f | list existing Bash functions (names + code) |
-F | list existing Bash functions (names only) |
-i myVariable | declare myVariable is an integer |
-r myVariable | declare myVariable is read-only |
declare - myVariable=value
declare - myVariable myVariable=value
1 -bash: a: readonly variableOr : readonly b=2; echo $b; b=1
2 -bash: b: readonly variable
readonly variables exist until the end of the shell process.
readonly a=1; echo $a
1
unset a
bash: unset: a: cannot unset: readonly variable
cat << EOF | gdb > attach $$ > call unbind_variable("a") > detach > EOF
GNU gdb (GDB) 7.4.1-debian Copyright (C) 2012 Free Software Foundation, Inc. (gdb) Attaching to process 29720 Reading symbols from /bin/bash...(no debugging symbols found)...done. Loaded symbols for /lib/x86_64-linux-gnu/libnss_files.so.2 0x00007fd61bed006e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) $1 = 0 (gdb) Detaching from program: /bin/bash, process 29720 (gdb) quit
echo $a
(nothing)
As of bash 4.2, declare -gr seems to be identical to readonly.
Sys. fich. Taille Util. Dispo Uti% Monté sur Language-dependant header line /dev/mapper/vg1-mysql 55G 15G 37G 29% /var/lib/mysql /dev/mapper/vg2-dump 20G 9,9G 8,9G 53% /var/lib/mysql/backup
Flag | Usage |
---|---|
-h --human-readable | print sizes in human readable format (e.g. 1K, 234M, 2G) |
-i --inodes | report inode usage instead of block usage |
-P --portability | use the POSIX output format :
|
-T --print-type | print filesystem type
This can be used to determine which filesystem a file belongs to :
df -T $HOME
Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/mapper/caramba--vg-home ext4 25066604 4086168 19684052 18% /home |
(9.|100)%
'; echo 'Inodes :'; df -Phi | grep '100%
'df is actually smart enough to determine which filesystem holds /path/to/myFile and report the usage :
Filesystem Size Used Avail Use% Mounted on /dev/mapper/caramba--vg-home 24G 3.9G 19G 18% /home
^/
" { print $5 }'18%
#!/usr/bin/env bash logFile=$0.csv hostName='www.example.com' serversList='DNS servers list' echo "DNS Server;Time [ms]" > $logFile for dnsServer in $serversList; do echo -n . echo -n "$dnsServer;" >> $logFile dig @$dnsServer $hostName | grep 'Query time' | cut -d ' ' -f 4 >> $logFile done
Flag | Usage |
---|---|
if=file | input file. This can be :
|
of=file | output file |
bs=n[unit] | block size
bs=64k only makes the transfer go faster because dd will be reading blocks of 64k each instead of the default block size (source).
|
count=n | generate n blocks of the specified size |
iflag=FLAG1,FLAG2,FLAGn | apply the specified flags to the read (input) file |
oflag=FLAG1,FLAG2,FLAGn | apply the specified flags to the written (output) file |
seek | offset |
status=level | the level of information to print to stderr :
|
Flag | Usage |
---|---|
-b myPackage --build myPackage |
build the myPackage.deb package (details) |
-c packageName --contents packageName |
show contents of packageName
packageName has to be available on the local filesystem
|
-i packageName | install the package packageName
Before actually installing, check dependencies are met with (source) :
dpkg --dry-run -i packageName packageName has to be available on the local filesystem
|
-I packageName --info packageName |
show information about packageName
packageName has to be available on the local filesystem
|
-l | list all the installed packages
|
-L packageName | List files installed by the package packageName |
-P packageName | Purge the package packageName : completely uninstall the package including binaries and configuration files |
-r packageName | remove the package packageName, leaving the configuration files untouched. |
-s packageName --status packageName |
display status information about the package packageName. (this actually reads the package control file) list packages on which packageName depends |
-S someFile --search someFile |
display which package installed someFile. Check it :
directory='/usr/bin'; nbFiles=$(ls -1 "$directory" | wc -l); randomNumber=$(shuf -i 1-$nbFiles -n 1); randomFile=$(ls -1 "$directory" | sed -n "$randomNumber p"); echo "Random file : '$directory/$randomFile'"; dpkgSResult=$(dpkg -S "$directory/$randomFile"); echo "... is from package : '$dpkgSResult'"; packageName=$(echo "$dpkgSResult" | cut -d':' -f1); echo "... which also installed : "; dpkg -L "$packageName" | grep "$directory"
If this fails saying :dpkg-query: no path found matching pattern someFile, it may be because someFile is a symlink.
|
Depends: mysql-server-5.5
mysql-server
Reverse Depends:
mysql-server-5.5
|yubikey-val meaning of this |
? Read below.
|yubikey-ksm
|spip
|prometheus-mysqld-exporter
openstack-cloud-services
mutt
Reverse Depends:
t-prot
notmuch-mutt
devscripts
urlview
urlscan
|sylph-searcher sylph-searcher depends on mutt or an alternate package (shown by the |
)
mixmaster
|metche
lbdb
automysqlbackup automysqlbackup depends on mutt, and there's no alternative
the listed packages have some kind of dependency on mutt (Depends, Recommends, Suggests, Enhances, ...)
Package: sylph-searcher Suggests: sylpheed | claws-mail | mutt | wl one of these will suffice Package: metche Depends: debconf (>= 0.5) | debconf-2.0, mutt | mailx | mail-transport-agent, bzip2, ucf debconf AND (mutt OR mailx OR mail-transport-agent) AND bzip2 AND ucf Package: automysqlbackup Recommends: mutt no alternative
Flag | Usage |
---|---|
--apparent-size | print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like |
-c | display a grand total |
--max-depth depth (Linux) -d depth (*BSD ?) |
display an entry for all files and directories depth directories deep max-depth conflicts with s |
-h | display results in human readable format |
-m | display file size in megabytes |
-S --separate-dirs | ignore subdirectory sizeThis REALLY ignores subdirectories ! |
-s | summarize : display only a total for each argument s conflicts with max-depth |
-x | only consider files that are on the same filesystem (=device) than the file given as parameter : du -x /. This prevents going into /mnt/... filesystems. |
The specified path must end with /*