Difference between revisions of "Programming/Linux"
Line 7: | Line 7: | ||
Popular Linux distributions include [https://www.debian.org/ Debian], [https://getfedora.org/ Fedora], and [https://ubuntu.com/ Ubuntu]. Commercial distributions include [https://www.redhat.com/ Red Hat Enterprise Linux] and [https://www.suse.com/ SUSE Linux Enterprise Server]. | Popular Linux distributions include [https://www.debian.org/ Debian], [https://getfedora.org/ Fedora], and [https://ubuntu.com/ Ubuntu]. Commercial distributions include [https://www.redhat.com/ Red Hat Enterprise Linux] and [https://www.suse.com/ SUSE Linux Enterprise Server]. | ||
= | = Learning about the system = | ||
== Which Linux? == | == Which Linux? == | ||
Line 30: | Line 30: | ||
5.4.0-1029-aws | 5.4.0-1029-aws | ||
</pre> | </pre> | ||
= Working with packages = | |||
== How to install a package? == | == How to install a package? == | ||
Line 69: | Line 71: | ||
sudo apt upgrade | sudo apt upgrade | ||
</pre> | </pre> | ||
= Working with files and directories = | |||
== What is the current directory? == | == What is the current directory? == | ||
Line 97: | Line 101: | ||
</pre> | </pre> | ||
where <tt>-a</tt> tells <tt>ls</tt> not to ignore entries starting with <tt>.</tt>, <tt>-l</tt> means that <tt>ls</tt> should use a long listing format, <tt>-t</tt> tells is to sort by modification time, newest first. (<tt>ls -a -l -t</tt> can be compressed into <tt>ls -alt</tt>.) | where <tt>-a</tt> tells <tt>ls</tt> not to ignore entries starting with <tt>.</tt>, <tt>-l</tt> means that <tt>ls</tt> should use a long listing format, <tt>-t</tt> tells is to sort by modification time, newest first. (<tt>ls -a -l -t</tt> can be compressed into <tt>ls -alt</tt>.) | ||
= DevOps = | |||
== What is my system currently doing? == | == What is my system currently doing? == |
Revision as of 14:23, 22 December 2020
Linux
Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on 1991.09.17 by Linux Torvalds. Linux is typically packaged in a Linux distribution.
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project.
Popular Linux distributions include Debian, Fedora, and Ubuntu. Commercial distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server.
Learning about the system
Which Linux?
To find out which Linux distribution is running on your machine, you can use
$ hostnamectl Static hostname: ip-172-31-24-17 Icon name: computer-vm Chassis: vm Machine ID: b54d0220fe634fa4a96fa3d0641ab3ea Boot ID: 5208456664c54b09b34be6b541fa7588 Virtualization: xen Operating System: Ubuntu 20.04.1 LTS Kernel: Linux 5.4.0-1029-aws Architecture: x86-64
More specifically, to find out the Kernel version, you can use
$ uname -r 5.4.0-1029-aws
Working with packages
How to install a package?
Use apt, the command line interface for the package management system.
Before proceeding, run
$ sudo apt update
update is used to download package information from all configured sources. Other commands operate on this data to e.g. perform package upgrades or search in and display details about all packages available for installation.
Once this is done, run
$ sudo apt install emacs
to install the GNU project Emacs editor,
$ sudo apt install mc
to install the GNU Midnight Commander. Other packages are installed in a similar manner.
How to find out which packages can be upgraded?
$ sudo apt list --upgradable
will produce a list of all packages that can be upgraded.
How to upgrade a package?
To upgrade a specific package, say emacs, you can use
sudo apt upgrade emacs
To upgrade all upgradable packages, use
sudo apt upgrade
Working with files and directories
What is the current directory?
To find out the current directory on a Linux system, use
$ pwd /home/ubuntu
How can I change the current directory?
The current directory can be changed using cd, for example:
~$ cd /var/www /var/www$
What are the contents of the current directory?
To list the contents of the current directory, you can use ls. In its most basic form, it's simply
$ ls
A useful variant is
$ ls -alt
where -a tells ls not to ignore entries starting with ., -l means that ls should use a long listing format, -t tells is to sort by modification time, newest first. (ls -a -l -t can be compressed into ls -alt.)
DevOps
What is my system currently doing?
To find out what the system is currently doing, including things such as CPU and memory utilization, you can use glances.
To install it, use
$ sudo apt update ... $ sudo apt install glances
Then run it using
$ glances