Processes

  • All running processes can actually be found in the /proc directory - for example: /proc/[pid].
  • To display processes:
ps aux
# -a stands for all
# -u stands for all processes by all users
# -x stands for all processes that don't run a tty.

# Kernel processes are in brackets, e.g.:
root        10  0.0  0.0      0     0 ?        S    ene14   0:00 [watchdog/0]
root        11  0.0  0.0      0     0 ?        S    ene14   0:00 [watchdog/1]
root        12  0.0  0.0      0     0 ?        S    ene14   0:00 [migration/1]
root        13  0.0  0.0      0     0 ?        S    ene14   0:00 [ksoftirqd/1]

Packages

  • Install packages with APT (nowadays you can just do apt install):
sudo apt-get install nmap
  • If you have a .deb:
sudo dpkg -i /path/to/deb/file
sudo apt-get install -f
  • Remove packages:
dpkg --list
sudo apt-get --purge remove packageName
sudo apt-get autoremove
  • Best practice for installing custom packages - try to do it in the /opt directory and create a symbolic link to /usr/bin.

Service Control

  • Systemctl (system/service control) can be used to enable and disable various services:
systemctl
  • For example, start/stop the SSH service:
systemctl start ssh
systemctl status ssh
systemctl stop ssh
  • You can verify that the service is listening for connection by running network status:
netstat -antp
  • For example, to make ssh and apache2 start on boot:
systemctl enable ssh
systemctl enable apache2
  • Init.d is just a wrapper around Systemctl:
/etc/init.d/cron status
/etc/init.d/cron start
/etc/init.d/cron stop
  • This is a tool to control services more easily, what is running upon boot and so on:
rcconf

Cronjobs

  • The scheduled tasks of Linux.
  • There are two ways to configure cronjobs. The first one is by putting scripts in the following folders:
/etc/cron.daily
/etc/cron.hourly
/etc/cron.weekly
/etc/cron.monthly
  • The second way is to use the crontab API, e.g. list cronjobs:
crontab -l
  • Edit or create new cronjobs:
crontab -e

Kernel

  • To update the kernel:
sudo apt-get update && sudo apt-get dist-upgrade
  • Or (For LTS / long term support) use this:
sudo apt-get update && sudo apt-get upgrade

Logging

  • Logs can be found in /var/log/. Usually.
  • More to come, possibly.

The Filesystem

  • The Filesystem Hierarchy Standard (FHS):

(linux-basics-filesystem.png)

  • To list all devices:
fdisk -l
  • Everything on Linux belongs to some part of the filesystem.
  • If we plug in some device we need to mount it to the filesystem!

  • To mount (connect):
mount /dev/usb /media/usb
  • To unmount:
umount /media/usb