From the course: Linux Tips
Process management: ps - Linux Tutorial
From the course: Linux Tips
Process management: ps
- [Instructor] On a Linux system, programs run within a process. A process allows us to keep track of a program that's running, and programs can start up sub-processes, or child processes, as they need to. The processes for a particular program are all related and can be managed individually or as a group. A common tool for finding out some information about processes that are running is called PS. If I run PS by itself, I can see the processes that are running inside the shell. Here's the shell, and here's PS. Because when it was running, it had a process of its own. The columns here start out with the PID, or process ID, the number that the system assigns to new processes. When a process ends, the number it was using is released, and the system can reuse it. Depending on your system, there's different limits for the number of processes that a particular user can start, though the user is generally not constrained within a limit. Every process takes resources though, so there are practical, not just theoretical, limits to how much stuff you can run. The next column is the terminal where a process is running. These are all in PTS one, because that's my pseudo-terminal that I'm running here. Time is how much time each command has taken so far. And CMD is the command that invoked the process. There's quite a few different options for changing the output and the scope of what's displayed. And I encourage you to take a look through the PS man page for more details. Let's look at a few options here though. I'll start up a series of nested bash shells. PS dash C and a command name will show you the processes that have that command name. I'll use bash, because I know I have a few of those running. And here they are. Combining that with the F option gives a more full listing. I'll write PS dash F capital C bash. This shows the user ID that started a command and the time that it was started up in addition to the parent process ID. And following through these, I can see that this process is the parent of this one. This process is the parent of this one, and so on. Modifying this can make it a little more helpful, like with the J and H options to make a tree format. I'll write PS dash J capital H C and bash. Capital H shows a hierarchical listing, and J shows output in the jobs format where we get process group ID and session ID values as well. You can see how that lines up with the groups of processes that are running under other processes or session leaders. The SID, or session ID, is the process ID of the session leader, which is responsible for all the processes, or jobs, underneath it in the tree. We can also take a look at what a particular user is running with the dash U or dash capital U option. Lowercase U shows the effective user, and capital U shows the real user. Let's see what my user has started here outside of just this shell. Alright, that's a lot of stuff, mostly from my desktop manager and the VirtualBox software. We can make this a little more readable, again, with F for full output, capital H for a hierarchical view, and U and the username. And that gives us a bit more of a picture of what processes are going on for this particular user. I can see all of the processes on a system with PS dash E for everything, which is kind of useful, especially in conjunction with some of the other options we saw earlier, like H for hierarchical view. PS is often used in conjunction with the kill command which sends interrupt signals to processes. There are various signals that kill can send to a process, some of which request that a process do whatever cleanup it needs to do before exiting or simply requesting that the process do whatever it's designed to do in response to an interrupt signal, which in some cases, doesn't end the process at all. The default signal is called sig term, which asks the process it's sent to to exit. Usually that will work to end a running process unless that process is stuck or, for some other reason, doesn't respond to this polite request. In that case, we can send a much more forceful signal called sig kill to the process instead, which immediately ends the process without waiting for it to respond. We can take a look at all of the signals available with kill dash lowercase L. Here's sig term, and here's sig kill. To specify the signal to use, we use dash and then the number. So dash nine is sig kill. Let's see what process my shell is here with PS dash capital C bash. Let's go for 2858. That's the parent process for these processes below it. I'll use kill dash nine to end that process, which will end all of the processes underneath it as well. And there goes my terminal. Using PS to track down a process is a great skill to have, and it can help you gain more insight as to what a system is doing.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
Foundations: What's Linux?5m 26s
-
Foundations: Distros10m 50s
-
(Locked)
Foundations: Installing Linux in a virtual machine6m 30s
-
(Locked)
Foundations: USB installer7m 46s
-
(Locked)
Foundations: Installing Linux5m 17s
-
(Locked)
Foundations: Dual-booting your system4m 18s
-
(Locked)
Foundations: Core Utilities4m 40s
-
(Locked)
Foundations: Linux on a VPS4m 2s
-
(Locked)
Linux on Azure7m 21s
-
(Locked)
Google Cloud Platform3m 37s
-
(Locked)
Linux on DigitalOcean6m 39s
-
-
-
System basics: The Linux file system6m 35s
-
(Locked)
System basics: The command line5m 23s
-
(Locked)
System basics: Keyboard shortcuts1m 40s
-
(Locked)
System basics: sudo access and root4m 57s
-
(Locked)
System basics: Explore a system4m 38s
-
(Locked)
System basics: Exploring Bash7m
-
(Locked)
System basics: Bash scripting basics4m 59s
-
(Locked)
System basics: The Bash prompt6m 2s
-
(Locked)
System basics: Bash output redirection4m 57s
-
(Locked)
Bash expansions and substitutions4m 23s
-
Bash aliases and functions4m 7s
-
(Locked)
Bash operators6m 55s
-
Logs5m 4s
-
(Locked)
Grub3m 19s
-
(Locked)
SysV init4m 43s
-
(Locked)
Systemd5m 29s
-
(Locked)
Cron8m 7s
-
(Locked)
Understanding chroot3m 16s
-
(Locked)
System basics: User and group management8m 39s
-
(Locked)
System basics: Service management3m 44s
-
(Locked)
Backing up data with rsync5m 35s
-
(Locked)
Splitting and combining files3m 3s
-
(Locked)
Environment configuration files2m 43s
-
(Locked)
Working with dotfiles1m 43s
-
(Locked)
Exploring the PATH variable3m 51s
-
(Locked)
Browsing with the directory stack3m 19s
-
(Locked)
Finding or locating files3m 52s
-
(Locked)
Working with swap4m 29s
-
(Locked)
Read and write caches3m 5s
-
(Locked)
Terminals, consoles, and TTYs4m 27s
-
(Locked)
Exploring journalctl5m 2s
-
-
-
Files on Linux4m 10s
-
(Locked)
File system basics: Archives6m 22s
-
(Locked)
File system basics: Permissions 1014m 43s
-
(Locked)
Loop devices4m 35s
-
(Locked)
Configuring group file shares4m 37s
-
Managing space on the file system5m 3s
-
(Locked)
Overlay file systems4m 17s
-
Bind mounts2m
-
(Locked)
Modifying the file system table7m 44s
-
(Locked)
Sticky bit4m 39s
-
(Locked)
Access control lists4m 6s
-
-
-
Working with text: Vim 1015m 15s
-
(Locked)
Working with text: Emacs 1015m 42s
-
(Locked)
Working with text: nano 1015m 29s
-
(Locked)
Working with text: grep4m 23s
-
(Locked)
Working with text: Regular expressions4m 57s
-
(Locked)
Working with text: sed7m 24s
-
(Locked)
Working with text: AWK2m 51s
-
(Locked)
Working with text: cut and sort4m 14s
-
(Locked)
Working with text: ed 1016m 17s
-
-
-
Package management: Basics6m 59s
-
(Locked)
aptitude5m 43s
-
(Locked)
dpkg2m 20s
-
(Locked)
yum and DNF4m 58s
-
(Locked)
RPM3m 24s
-
(Locked)
Creating your own packages3m 12s
-
(Locked)
Adding third-party repositories with APT7m 6s
-
(Locked)
Adding third-party repositories with Yum1m 46s
-
(Locked)
Create a local APT repository7m 25s
-
(Locked)
Create an APT repository for your network5m 56s
-
(Locked)
Mirror repositories to save bandwidth3m 5s
-
(Locked)
Zypper4m 17s
-
(Locked)
Using Flatpak4m 11s
-
(Locked)
Using snaps3m 15s
-
(Locked)
Package management: PPAs4m 24s
-
(Locked)
Homebrew package management7m 43s
-
(Locked)
Using AppImage apps2m 34s
-
-
-
Remote files: curl and wget4m 42s
-
(Locked)
SSH: Secure access8m 8s
-
(Locked)
SSH: Transferring files with scp and sftp5m 59s
-
(Locked)
SSH: Managing and distributing keys6m 34s
-
(Locked)
SSH: Tunnels3m 46s
-
(Locked)
Browsing the web through a proxy server4m 28s
-
(Locked)
X11 forwarding2m 52s
-
(Locked)
Using a SOCKS proxy4m 53s
-
(Locked)
Using a Squid proxy8m 43s
-
(Locked)
Using mosh5m 11s
-
(Locked)
SSH: Reverse tunnel4m 1s
-
-
-
Process management: ps4m 30s
-
(Locked)
Process management: top4m 53s
-
(Locked)
Process management: htop6m 11s
-
(Locked)
Process management: System load2m 53s
-
(Locked)
Process management: fg, bg, and kill4m 35s
-
(Locked)
Manage terminal sessions with screen4m 17s
-
(Locked)
Manage terminal sessions with tmux3m 16s
-
(Locked)
Customizing tmux3m 32s
-
-
-
Firewall basics4m 5s
-
(Locked)
Understanding iptables6m 41s
-
(Locked)
Exploring UFW: Uncomplicated firewall5m 29s
-
(Locked)
File checksums3m 48s
-
(Locked)
Services: Network Time Protocol (NTP)3m 45s
-
(Locked)
Encrypting files7m 14s
-
(Locked)
Encrypted filesystems6m 58s
-
AppArmor4m 2s
-
(Locked)
Security systems: SELinux4m 33s
-
(Locked)
Firewalls: firewalld7m 41s
-
-
-
(Locked)
Disks and partitions6m 42s
-
(Locked)
Logical volume management9m 58s
-
(Locked)
Create a RAID array9m 10s
-
(Locked)
Repairing a RAID array4m 44s
-
(Locked)
Local IP address5m 15s
-
(Locked)
Predictable network interface names4m 51s
-
(Locked)
DNS5m 40s
-
(Locked)
VPN1m 43s
-
(Locked)
Exploring system hardware5m 7s
-
(Locked)
Drivers and modules4m 16s
-
(Locked)
Understanding QEMU and KVM2m 49s
-
(Locked)
Creating a VM with QEMU and KVM3m 46s
-
(Locked)
Private networking6m 37s
-
(Locked)
Routing and forwarding4m 26s
-
(Locked)
DHCP4m 55s
-
(Locked)
Network troubleshooting7m 42s
-
(Locked)
Wi-Fi on Linux4m 14s
-
(Locked)
Set up a secure tunnel with WireGuard8m 38s
-
(Locked)
Scanning network ports with Nmap4m 28s
-
(Locked)
-
-
(Locked)
Desktops: Basics3m 8s
-
(Locked)
Desktops: GNOME4m 41s
-
(Locked)
Desktops: Xfce4m 5s
-
(Locked)
Desktops: KDE Plasma Desktop2m 28s
-
(Locked)
Desktops: LXQt3m 42s
-
(Locked)
Desktops: i3wm5m 8s
-
(Locked)
Sharing your desktop with VNC5m 8s
-
(Locked)
Remote desktop login with xrdp5m 14s
-
(Locked)
Display geometry with GRUB5m 21s
-
(Locked)
Display geometry with xrandr4m 4s
-
(Locked)
-
-
(Locked)
Exploring Windows Subsystem for Linux2m 20s
-
(Locked)
Windows Subsystem for Linux7m 20s
-
(Locked)
Exploring virtualization5m 28s
-
(Locked)
Exploring containers5m 19s
-
(Locked)
Exploring Fedora3m 8s
-
(Locked)
Ubuntu desktop 18.042m
-
(Locked)
Changing the default shell3m 30s
-
(Locked)
Exploring other shells2m 5s
-
(Locked)
Blocking ads on your network with Pi-hole6m 35s
-
(Locked)
Exploring CentOS2m 6s
-
(Locked)
Exploring Zsh5m 41s
-
(Locked)
Osquery4m 28s
-
(Locked)
Exploring fish5m 21s
-
Exploring csh and tcsh2m 34s
-
(Locked)
Using diff to compare files3m 54s
-
(Locked)
Using xargs3m 41s
-
(Locked)
Configuring and managing logs4m 32s
-
(Locked)
Job control3m 59s
-
(Locked)
Using watch and time3m 5s
-
(Locked)
Recording a terminal session3m 14s
-
(Locked)
Exploring Debian1m 49s
-
(Locked)
Exploring SUSE Linux7m 33s
-
(Locked)
Exploring Arch Linux16m 44s
-
(Locked)
Exploring Alpine Linux6m 18s
-
(Locked)
Exploring Linux Mint5m 14s
-
(Locked)
Exploring Amazon Linux5m 8s
-
(Locked)
UNIX time and the 2038 problem6m 36s
-
(Locked)
Visual file management with Midnight Commander5m 42s
-
(Locked)
Terminal on the go5m 1s
-
(Locked)
FUSE and SSHFS3m 54s
-
(Locked)
Removing Linux4m 44s
-
(Locked)
WSL distros on Windows 103m 13s
-
(Locked)
Embedded Linux4m 25s
-
(Locked)
Exploring Netboot2m 43s
-
(Locked)
Exploring ZFS3m 53s
-
(Locked)
Docker on Linux5m 24s
-
(Locked)
-
-
(Locked)
Planning a home server6m 11s
-
(Locked)
Backups with rsync6m 18s
-
Linux on an old PC6m 7s
-
(Locked)
Creating a disk image with dd3m 54s
-
(Locked)
Mounting and writing disk images with dd7m 1s
-
(Locked)
Migrating to a new distro4m 33s
-
(Locked)
Planning a portable bootable disk3m 12s
-
(Locked)
Creating a portable bootable disk5m 30s
-
(Locked)
Host your own Apache web server5m 32s
-
(Locked)
Set up Let’s Encrypt on a web server5m 3s
-
Host a personal cloud with Nextcloud4m 50s
-
(Locked)
Hosting email services3m 7s
-
(Locked)
Set up a print server with CUPS6m 5s
-
(Locked)
Create a network PDF printer4m 37s
-
(Locked)
Remote logging with Rsyslog7m 12s
-
(Locked)
Set up a Git server4m 15s
-
(Locked)
NGINX web server4m 11s
-
(Locked)
Share files with a Samba server3m 35s
-
(Locked)
Set up an NFS server3m 58s
-
(Locked)
Monitoring your server2m 49s
-
(Locked)
Exploring Internet Relay Chat (IRC)6m 6s
-
(Locked)
Keep on learning!35s
-
(Locked)