Important Uses
On Ubuntu Server 20.04 LTS
Install updates via command line
sudo apt update # Fetches the list of available updates
sudo apt upgrade # Installs some updates; does not remove packages
sudo apt autoremove # Removes any old packages that are no longer needed. This also removes older kernels. Only latest two are kept.
Usage "autoclean", "autoremove" and "clean"
From the apt-get
man page:
clean: clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. When APT is used as a dselect(1) method, clean is run automatically. Those who do not use dselect will likely want to run apt-get clean from time to time to free up disk space.
autoclean: Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.
autoremove: is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no longer needed.
Every command has a manual page, if you want to know what their parameters are or what each of them do, just type in the shell `man ` Ex. `man apt-get
manpage for the apt-get
command
3. How to uninstall or remove <installed-application> software package from Ubuntu server.
You can uninstall or removes any installed software package itself from Ubuntu server through the terminal. Let us uninstall grub-common software packages from our system.
$ sudo apt-get remove grub-common
Uninstall grub-common including dependent package
If you would like to remove grub-common and it's dependent packages which are no longer needed from Ubuntu
$ sudo apt-get remove --auto-remove grub-common
Use purging grub-common
If you use with purge options to grub-common package all the configuration and dependent packages will be removed
$ sudo apt-get purge grub-common
If you use purge options along with auto remove, will be removed everything regarding the package, It's really useful when you want to reinstall again
$ sudo apt-get purge --auto-remove grub-common
Remove update link error - Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings.
sudo truncate -s 0 /var/lib/ubuntu-release-upgrader/release-upgrade-available
5. Scroll/Navigate on ubuntu server
ls -l | less
The bar in the middle of the two commands is called the “pipe” which is the character option above the \
character on US keyboards. So in essence, you are taking the output of ls -l
and piping it into the pager program on Linux called less
or try more
if less
is not found. less
will take all of the output from ls -l
and present it to you one page at a time.
Create and extract
tar
archive files
tar -xvzf psp_docs.tar.gz
The tar utility is pre-installed by default on all Linux distributions. In the above uses, tar
collected all the files into one package, psp_docs.tar
. The gzip program applied compression, hence the gz
extension. So the command does a couple things:
f
: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.z
: tells tar to decompress the archive using gzipx
: tar can collect files or extract them.x
does the latter.v
: makes tar talk a lot. Verbose output shows you all the files being extracted.
To extract into a custom folder, add the -C
option with a folder name of your choice:
tar -xvzf psp_docs.tar.gz -C some_custom_folder_name
Type man tar
for more information.
To compress a directory with tar
using mazimum compression using xz
XZ_OPT='-9' tar -cvJf backup.tar.xz -C /path/to/input/file/backup .
Where tar options for the xz command are as follows:
-c : Create a new tar archive
-v : Verbose output
-J : Use the xz compression by calling the xz command
-f : Archive name
To extract a tar.xz
file, invoke the tar
command with the --extract
(-x
) option and specify the archive file name after the -f
option:
tar -xf archive.tar.xz
For more verbose output, use the -v
option. This option tells tar
to display the names of the files being extracted on the terminal.
tar -xvf archive.tar.xz
To list the content of a tar.xz file, use the --list
(-t
) option:
tar -tf archive.tar.xz
To extract archive files in a specific directory, use the --directory
(-C
)
tar -xf archive.tar.xz -C /home/cardano/files
When extracting a compressed tar.xz
file by reading the archive from standard input (usually through piping), you must specify the decompression option. The -J
option tells tar
that the file is compressed with xz
wget -qO- "YOUR_DOWNLOAD_LINK.tar.xz" | tar -xJ
curl -sL "YOUR_DOWNLOAD_LINK.tar.xz" | tar -xJ
To extract archive files in a specific directory, use the --directory
(-C
)
wget -qO- "YOUR_DOWNLOAD_LINK.tar.xz" | tar -xJ -C /target/directory
curl -L <YOUR_DOWNLOAD_LINK.tar.xz> | tar -xJ -C /target/directory
To show the progress, the --show-progress
option is used
wget -q -O - --show-progress "http://example.com/path/to/archive.tar.gz" | tar -xJ -C /path/to/extract
Last updated