Chapter 1 Linux utilities
1.1 Directories listing and size
1.1.1 du: file space usage
du
is an utility to estimate file space usage. It estimates recursively the disk usage
of the files inside the directory supplied. You can supply diferent sub-directories using
syntax path/*
. Useful arguments are:
-s, --summarize
: display the total space usage for each argument,-h, --human-readable
: print usage in human readable format,-d, --max-depth=N
: print total for subdirectories with depthN
,--aparent-size
: aparent size is usually smaller,-c, --total
: show grand total.
See some examples below:
1.2 Download data
Common command to download data are wget
and curl
.
1.2.1 wget: network downloader
wget
is an utility to download files from the web. By default, it write the output to a
file with the same name as remote. In case the file exists, it will append an index (.1
,
.2
, .3
, and so on) and to create a new file.
-O <file>, --output-document=<file>
: write output to<file>
,--quiet
: do not show messages.
See some examples below:
# download a file from github
wget https://raw.githubusercontent.com/ErickChacon/dotfiles-ubuntu-18/master/.config/nvim/init.vim
# download a file from github to standard output
wget -O - https://raw.githubusercontent.com/ErickChacon/dotfiles-ubuntu-18/master/.config/nvim/init.vim
# download rclone installer to a file called `rclone-install.sh`
wget -O rclone-install.sh https://rclone.org/install.sh
1.2.2 curl: transfer data
curl
is an utility to transfer data from or to a server. I mainly use this to download
files. Common arguments I use in priority order are:
-O, --remote-name
: write output to a file with same name as remote,-L, --location
: redirect request in case URL has been modified.-o, --output <file>
: write output to<file>
,-s, --silent
: do not show progress neither error messages,-S, --show-error
: show error messages,
See some examples below:
# download a file from github
curl -OL https://raw.githubusercontent.com/ErickChacon/dotfiles-ubuntu-18/master/.config/nvim/init.vim
# download a file from github to standard output
curl https://raw.githubusercontent.com/ErickChacon/dotfiles-ubuntu-18/master/.config/nvim/init.vim
# download rclone installer to a file called `rclone-install.sh`
curl -L -o rclone-install.sh https://rclone.org/install.sh
1.4 Create a bootable installer
- Download the image
- Insert a usb stick
- Copy the installer in the usb stick
cp debian-9.0.0-amd64-DVD-1.iso /dev/sda
sync
1.7 Remove and install packages a package
1.9 Tinytex for R
1.10 Check for badclocks
sudo fdisk -l # check block size
badblocks -sv /dev/nvme0n1 # only-reading
badblocks -nsv /dev/nvme0n1 # writing-reading (non-destructive)
badblocks -wsv /dev/nvme0n1 # writing-reading (destructive)
badblocks -wsv -o badblocks.txt /dev/nvme0n1 # writing-reading (destructive) and save
11169-11223 414725-414727
PCIe SSD
e2fsck -c mke2fs