Linux LPIC
Linux LPIC
You are authorized to use and share this guide both in electronic and in printed form (for instance as a course material),
provided that you distribute intact either the whole guide or the single pages, and you do it not-for-profit. For any other use
please email me. Feel free to contact me also for any error, inaccuracy, or unclear point so I can correct it in future versions.
Daniele Raffo
Index
Hardware settings............................1 Links............................................14 E-mail...........................................27
/proc filesystem...............................2 Find system files............................15 Printing.........................................28
System boot....................................3 Shell environment..........................16 Network addressing........................29
Runlevels........................................4 Scripting.......................................17 Subnetting....................................30
Fileystem........................................5 Flow control...................................18 Network services............................31
Partitions........................................6 SQL..............................................19 Network tools................................32
Boot manager..................................7 X Window System..........................20 Network scanning...........................33
Shared libraries...............................8 User accounts................................21 Net config files...............................34
Package management.......................9 User management..........................22 Net config commands.....................35
Command line...............................10 Job scheduling...............................23 SSH..............................................36
Text streams..................................11 Localization...................................24 GPG.............................................37
Processes......................................12 System time..................................25 OpenSSL.......................................38
File permissions.............................13 Logging.........................................26 Key bindings..................................39
Linux
Professional
Institute 1/39 Hardware settings
Hardware settings
hdparm Get/set disk parameters
hdparm -g /dev/sda Display drive geometry (cylinders, heads, sectors) of /dev/sda
hdparm -tT /dev/sda Perform benchmarks on the /dev/sda drive
hdparm -p 12 /dev/hda Reprogram IDE interface chipset of /dev/sda to mode 4. Use with caution!
The Hardware Abstraction Layer (HAL) manages device files and provides plug-and-play facilities. The HAL daemon hald
maintains the list of devices in a database.
udev creates the device nodes in /dev/. When a device is added, removed, or changes state, the kernel sends an uevent
received by the udevd daemon.
udevadm monitor (Debian)
Monitor uevents
udevmonitor (Red Hat)
dbus-monitor Monitor messages going through a D-Bus message bus
dbus-monitor --session Monitor session messages (default)
dbus-monitor --system Monitor system messages
Almost all Linux commands accept the option -v (verbose), and many commands also accept the option -vv (very verbose).
/proc filesystem
System boot
Boot sequence
POST
Low-level check of PC hardware.
(Power-On Self Test)
BIOS
Detection of disks and hardware.
(Basic I/O System)
GRUB stage 1 is loaded from the MBR and executes GRUB stage 2 from filesystem.
Chain loader
GRUB chooses which OS to boot on.
GRUB
The chain loader hands over to the boot sector of the partition on which resides the OS.
(GRand Unified
The chain loader may also load initrd, an initial ramdisk to be used as the initial root
Bootloader)
device during kernel boot.
Kernel decompression into memory.
Kernel execution.
Linux kernel
Detection of devices.
Root filesystem is mounted on / in place of the initial ramdisk.
Runlevels
runlevel
who -r Display the previous and the current runlevel
init [runlevel]
telinit [runlevel] Change runlevel
init 0
shutdown -h now Halt the system
halt
init 6
shutdown -r now Reboot the system
reboot
shutdown -h 16:00 "System halt at 4 PM" Halt the system at 4 PM and issue a warning message to all
logged in users
Fileystem
Linux-supported filesystems
ext2 Linux filesystem
ext3 ext2 with journaling
(the journal logs changes before committing them to the filesystem;
ensures faster recovery and less corruption in case of a crash)
ext4 Linux journaling filesystem
reiserfs Journaling filesystem
fat32 MS-Windows FAT filesystem
iso9660 CD-ROM filesystem
cramfs Compressed RAM disk
Partitions
/dev/hda, /dev/hdb, ... first, second, ... IDE hard drive
/dev/sda, /dev/sdb, ... first, second, ... SATA hard drive
/dev/sda1, /dev/sda2, ... first, second, ... partition of the first SATA drive
The Logical Volume Manager permits disk hotswapping, partition resizing, dynamic logical volume assignment, backup via
snapshots.
The superblock contains information relative to the filesystem (filesystem type, size, status, metadata structures...).
The Master Boot Record (MBR) is a 512-byte program located in the first sector of the hard disk; it contains information about
hard disk partitions and has the duty of loading the OS.
mount /dev/sda /mnt Mount a filesystem to mount point /mnt (mount directory must exist)
mount Print the currently mounted filesystems
Boot manager
GRUB (Grand Unified Bootloader) is the standard bootloader on modern Linux distros, which may use either version: GRUB
Legacy or GRUB 2.
Older Linux distros used LILO (Linux Loader) instead.
GRUB Stage 1 (446 bytes), as well as the partition table (64 bytes) and the boot signature (2 bytes), is stored in the 512-
byte MBR. It accesses the GRUB configuration and commands available on the filesystem.
# Windows
menuentry "Windows" {
set root=(hd0,2)
chainloader +1
}
Shared libraries
The runtime loader ld.so loads the required libraries of the program into RAM, searching in this order:
LD_LIBRARY_PATH Environment variable specifying the list of directories where libraries should be searched for first
/etc/ld.so.cache Cache file
/lib and /usr/lib Default locations for shared libraries
Package management
Upgrade a package
rpm -F package.rpm
(only if an old version is already installed)
Text-based UI or
aptitude
Manage packages and dependencies
graphical tools dselect
Convert a RPM package to DEB and installs it.
alien -i package.rpm
Other tools May break the package system!
Command line
man 7 [command] Show manpage 7 for a command
vlock
away Lock the virtual console (terminal)
Bash shortcuts
. Current directory
.. Parent directory
~ Home directory of current user
~jdoe Home directory of user jdoe
Text streams
cat myfile Print a text file
cat myfile1 myfile2 > myfile3 Concatenate text files
head myfile
head -n 10 myfile Print the first 10 lines of a text file
tail myfile
tail -n 10 myfile Print the last 10 lines of a text file
tail -f myfile Output appended data as the text file grows; useful to read logs in realtime
tac myfile Print a text file in reverse, from last line to first line
fmt -w 75 myfile Format a text file so that each line has a max width of 75 chars
pr myfile Format a text file for a printer
join myfile1 myfile2 Join lines of two text files on a common field
paste myfile1 myfile2 Merge lines of text files
split -l 1 myfile Split a text file into 1-line files (named xaa, xab, xac, ...)
uniq myfile Print the unique lines of a text file, omitting consecutive identical lines
sort myfile Sort alphabetically the lines of a text file
expand myfile Convert tabs into spaces
unexpand myfile Convert spaces into tabs
cut -d: -f3 myfile Cut the lines of a file, considering : as the delimiter and printing only the 3rd field
cut -d: -f1 /etc/passwd Print the list of user accounts in the system
sed s/foo/bar/ myfile Replace the first occurrence of foo with bar (Stream Editor)
sed s/foo/bar/g myfile Replace all occurrences of foo with bar
tr -d 0-9 <myfile
tr -d [:digit:] <myfile Delete all digits from a text file
Processes
Any application/program/script that runs on the system is a process. Signals are used for inter-process communication.
Each process has an unique PID (Process ID) and a PPID (Parent Process ID); when a process spawns a child, its PID is
assigned as the child's PPID.
The /sbin/init process, run at bootup, has PID 1; is the ancestor of all processes and becomes the parent of any orphaned
process.
When a child process dies, its status becomes EXIT_ZOMBIE and a SIGCHLD is sent to the parent. The parent should then
call the wait() system call to read the dead process' exit status and other info; until that moment, the child stays zombie.
free Show the amount of free and used memory in the system
vmstat Show virtual memory statistics
uptime Show how long the system has been up, and the system load averages
jobs List all jobs (i.e. processes whose parent is a Bash shell)
CTRL Z Suspend a job, putting it in the stopped state (send a SIGTSTP)
bg %1 Put job #1 in the background (send a SIGCONT)
fg %1 Resume job #1 in the foreground and make it the current job (send a SIGCONT)
kill %1 Kill job #1
When a Bash shell is terminated cleanly via exit, its jobs will became child of the Bash's parent and will continue running.
When a Bash is killed instead, it issues a SIGHUP to his children which will terminate.
nohup myscript.sh Prevent a process from receiving a SIGHUP (hence terminating) when its parent Bash dies
To each process is associated a niceness value: the lower the niceness, the higher the priority.
The niceness value ranges from -20 to 19, and a newly created process has a default niceness of 0.
Unprivileged users can modify a process' niceness only within the range from 1 to 19.
nice -n -5 [command] Start a command with a niceness of -5 (if niceness is omitted, a default value of 10 is used)
renice -5 [command] Change the niceness of a running command to -5
File permissions
- r w x r w x r w x
--==regular
regularfile
file user
user(owner)
(owner) group
group others
others
dd==directory
directory
ll==symbolic
symboliclink
link rr==read
read rr==read
read rr==read
read
ss==Unix
Unixdomain
domainsocket
socket ww==write
write ww==write
write ww==write
write
pp==named
namedpipe
pipe xx==execute
execute xx==execute
execute xx==execute
execute
cc==character
characterdevice
devicefile
file ss==setUID
setUIDand
andexecute
execute ss==setGID
setGIDand
andexecute
execute tt==sticky
stickyand
andexecute
execute
bb==block
block devicefile
device file SS==setUID
setUIDand
andnot
notexecute
execute SS==setGID
setGIDand
andnot
notexecute
execute TT==sticky
stickyand
andnot
notexecute
execute
Read group: 40 chmod g+r Can open and read the file Can list directory content
others: 4 chmod o+r
chmod +wx file Add write and execute permission to everybody (user, group, and others)
chown root:mygroup file Change the owner of file to root, and the group of file to mygroup
The chmod, chown, and chgrp commands accept the option -R to recursively change properties of files and directories.
Set the permission mask to 022, hence masking write permission for group and others.
umask 022 Linux default permissions are 0666 for files and 0777 for directories. These base permissions are ANDed
with the inverted umask value to calculate the final permissions of a new file or directory.
Links
A Linux directory contains a list of structures, which are associations between a filename and an inode.
An inode contains file metadata: file type, permissions, owner, group, size, access/change/modification/deletion times,
number of links, attributes, ACLs, and address where the actual file content (data) is stored.
Yes No
If original file is moved or deleted,
(because the link references the inode (the path now references a non-
is the link still valid?
the original file pointed to) existent file)
No
Can link to a file in another
(because inode numbers make sense Yes
filesystem?
only within a determinate filesystem)
Can link to a directory? No Yes
Reflect the original file's permissions,
Link permissions rwxrwxrwx
even when these are changed
Link attributes - (regular file) l (symbolic link)
Inode number The same as the original file A new inode number
whereis command Locate the binary, source, and manpage files for command
whereis -b command Locate the binary files for command
whereis -s command Locate the source files for command
whereis -m command Locate the manpage files for command
Shell environment
\ls
Run the non-aliased version of the command ls
/bin/ls
Scripting
Scripts must start with the shebang line #! /bin/bash indicating the location of the script interpreter.
Script execution
source myscript.sh Script execution takes place in the same shell. Variables defined and
. myscript.sh exported in the script are seen by the shell when the script exits
bash myscript.sh
Script execution spawns a new shell
./myscript.sh (file must be executable)
MYVAR=`date`
MYVAR=$(date) Assign to a variable the output resulting from a command
zenity Display GTK+ graphical dialogs for user messages and input
Flow control
test $MYVAR = "myvalue" && mycommand
[ $MYVAR = "myvalue" ] && mycommand Perform a test; if it holds true, the command is executed
if [ $MYVAR = "myvalue" ]; then mycommand; fi
Test operators
Integer operators File operators Expression operators
-eq Equal to -e or -a Exists -a Logical AND
-ne Not equal to -d Is a directory -o Logical OR
-lt Less than -b Is a block special file ! Logical NOT
-le Less than or equal to -c Is a character special file \( \) Priority
-gt Greater than -f Is a regular file
-ge Greater than or equal to -r Is readable
String operators -w Is writeable
-z Is zero length -x Is executable
-n or nothing Is non-zero length -s Is non-zero length
= or == Is equal to -u Is SUID
!= Is not equal to -g Is SGID
< Is alphabetically before -k Is sticky
> Is alphabetically after -h Is a symbolic link
expr $MYVAR = "39 + 3" Evaluate an expression; the variable will hold the value 42
expr [string] : [regex] Return the length of the substring matching the regex
expr [string] : \([regex]\) Return the substring matching the regex
Evaluation operators
= Equal to + Plus string : regex
String matches regex
!= Not equal to - Minus match string regex
Tests
if [test 1] case $VAR in
then [pattern 1]) [command 1] ;;
[command block 1] [pattern 2]) [command 2] ;;
elif [test 2] *) [command 3]
then esac
[command block 2]
else
[command block 3]
fi
Loops
while [test] for $I in [list] break Terminate a loop
do do
[command block] [command operating on $I] continue Jump to the next iteration
done done
SQL
SQL syntax
SELECT * FROM tableCustomers ORDER BY columnLastname LIMIT 5; Select only the first 5 records of customers
as ordered by last name
SELECT columnFirstname, columnLastname FROM tableCustomers WHERE Select only first and last name of customers
columnZipcode = 00123; whose zip code is 00123
SELECT columnCustomerID, SUM(columnSalary) FROM tablePayments Select all salary payments grouped by
GROUP BY columnCustomerID; customer ID, summed up
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('p4ssw0rd'); Set a password for a MySQL user
mysql -u root -p -e 'CREATE DATABASE NewDatabase' Create a new database by passing a SQL command to MySQL
X Window System
Display Managers
Display Manager Configuration files Display Manager greeting screen
/etc/init.d/xdm start Start the X Display Manager (gdm or kdm are started in a similar way)
xhost + 10.3.3.3 Add 10.3.3.3 to the list of hosts allowed to make X connections to the local machine
xhost - 10.3.3.3 Remove 10.3.3.3 from the list of hosts allowed to make X connections to the local machine
$DISPLAY Environment variable defining the display name of the X server, in the form
hostname:displaynumber.screennumber
User accounts
root:x:0:0:/root:/bin/bash
bin:x:1:1:/bin:/bin/bash
jdoe:x:500:100:John Doe,,555-1234,,:/home/jdoe:/bin/bash
1 2 3 4 5 6 7
1 Login name
2 Encrypted password (obsolete), or x if password is in /etc/shadow
3 UID – User ID (UID 0 is superuser; by convention UIDs 1-99 are system accounts, UIDs above are regular users)
4 GID – Default Group ID
5 GECOS field – Information about the user: Full name, Room number, Work phone, Home phone, Other
6 Home directory of the user
7 Login shell (can be set to /bin/false to prevent a user from logging in)
root:fZPe54/Kldu6D32pl0X/A:15537:0:99999:7:::
bin:*:15637:0:99999:7:::
jdoe:!hsp\8e3jCUdw9Ru53:15580:0:99999:7::15766:
1 2 3 4 5 6 7 8 9
1 Login name
2 Encrypted password (a ! prefix if the account is locked), * if account is disabled, ! or !! if no password
3 Date of last password change (in number of days since 1 January 1970)
4 Days before password may be changed; if 0, user can change the password at any time
5 Days after which password must be changed
6 Days before password expiration that user is warned
7 Days after password expiration that account is disabled
8 Date of account disabling (in number of days since 1 January 1970)
9 Reserved field
User management
useradd -m jdoe Create a user account, creating and populating his homedir from /etc/skel
useradd -mc "John Doe" jdoe Create a user account, specifying his full name
useradd -ms /bin/ksh jdoe Create a user account, specifying his login shell
useradd -D Show default values (specified in /etc/login.defs) for user account creation
usermod -c "Jonas Doe" jdoe Modify the GECOS field of a user account
(usermod accepts many
usermod -L jdoe Lock a user account
usermod -U jdoe useradd options)
Unlock a user account
chage -E 2013-02-14 jdoe Change the password expiration date, locking the account at that date
chage -d 13111 jdoe Change the date (in number of days since 1 January 1970) of last password change
chage -d 0 jdoe Force the user to change password at his next login
chage -M 30 jdoe Change the max number of days during which a password is valid
chage -m 7 jdoe Change the min number of days between password changes
chage -W 15 jdoe Change the number of days before password expiration that the user will be warned
chage -I 3 jdoe Change the number of days after password expiration before the account is locked
chage -l jdoe List password aging information for a user
adduser
deluser
addgroup User-friendly front-ends for user and group management (Debian)
delgroup
who am i
whoami Print your effective user ID
su jdoe Run a shell as the specified user. If user is not specified, assume root
su -c "fdisk -l" Pass a single command to the shell
su - Ensure that the spawned shell is a login shell, hence running login scripts and setting
su -l the correct environment variables. Recommended option
sudo fdisk -l Run a command as root. Sudo commands are logged via syslog
sudo -ujdoe fdisk -l Run a command as another user
sudoedit /etc/passwd Edit a protected file. It is recommended to use this instead of allowing users to sudo
sudo -e /etc/passwd text editors as root, which is a security problem if the editor spawns a shell
visudo Edit /etc/sudoers, the configuration file that specifies access rights to sudo
/etc/nologin If this file exists, login and sshd deny login to the system
Job scheduling
cron – repeated scheduled execution
/etc/crontab
The crond daemon checks the /etc/crontab system-wide file every minute and executes command as user at the specified
times.
Each user may also set his own crontab scheduling, which will result in a file /var/spool/cron/[user]. A user' crontab file
has the same format, except that the user field is not present.
/etc/anacrontab
If /etc/cron.allow exists, only users listed therein can access the service.
If /etc/cron.deny exists, all users except those listed therein can access the service.
If none of these files exist, all users can access the service.
If /etc/at.allow exists, only users listed therein can access the service.
If /etc/at.deny exists, all users except those listed therein can access the service.
If none of these files exist, no user except root can access the service.
at -d 3
atrm 3 Remove job number 3 from the list
Localization
LC_MESSAGES Language and encoding of system messages and user The list of supported locales is stored in
input /usr/share/i18n/SUPPORTED
LC_PAPER Paper size
LC_NAME Personal name formats
LC_ADDRESS Geographic address formats
LC_TELEPHONE Telephone number formats
LC_MEASUREMENT Measurement units (metric or others)
LC_IDENTIFICATION Metadata about locale
LC_ALL Special variable overriding all others
apt-get install manpages-it language-pack-it Install a different locale (system messages and manpages)
iconv -f IS6937 -t IS8859 myfilein > myfileout Convert a text file from a codeset to another
System time
tzselect
tzconfig Set the timezone, stored in /etc/timezone
dpkg-reconfigure tzdata (Debian)
Timezone is also set as a symbolic link from /etc/localtime to the correct timezone file in /usr/share/zoneinfo/
ntpd NTP daemon, keeps the clock in sync with Internet time servers
ntpd -q Synchronize the time once and quit
ntpd -g Force NTP to start even if clock is off by more than the panic threshold (1000 secs)
ntpd -n -g -q Start NTP as a non-daemon, force set the clock, and quit
ntpdate [server] Synchronizes the clock with the specified time server
ntpdate -b [server] Brutally set the clock, without waiting for a slow adjusting
ntpdate -q [server] Query the time server without setting the clock
hwclock --show
hwclock -r Show the hardware clock
hwclock --hctosys
hwclock -s Set the system time from the hardware clock
hwclock --systohc
hwclock -w Set the hardware clock from system time
hwclock --utc Indicate that the hardware clock is kept in Coordinated Universal Time
hwclock --localtime Indicate that the hardware clock is kept in local time
Logging
syslogd Daemon logging events from user processes
Syslog logging facility: klogd Daemon logging events from kernel processes
/etc/syslog.conf
# facility.level action
*.info;mail.none;authpriv.none /var/log/messages
authpriv.* /var/log/secure
mail.* /var/log/maillog
*.alert root
*.emerg *
local5.* @10.7.7.7
local7.* /var/log/boot.log
† deprecated
logger -p auth.info "Message" Send a message to syslogd with the specified facility and priority
logrotate Rotate logs (by gzipping, renaming, and eventually deleting old logfiles) according to
/etc/logrotate.conf
tail -f /var/log/messages Print the last lines of a file, moving forward as the file grows (useful to read logs in
real-time)
/var/log/messages
/var/log/syslog System and kernel logs
/var/log/kern.log
~/.forward Specifies one or more mail addresses to forward the user's mail to
/etc/aliases Aliases database for users on the local machine; each line is on the
/etc/mail/aliases form alias: user
newaliases
sendmail -bi Update the aliases database (must be run after any change)
Exim (MTA)
mailq
exim4 -bp Examine the mail queue
Printing
cupstestppd LEXC510.ppd Test the conformance of a PPD file to the format specification
cupsaddsmb printer0 Export a printer to SAMBA (for use with Windows clients)
mpage file.ps Print a PostScript document on multiple pages per sheet on a PostScript printer
Network addressing
IPv4 IPv6
32-bit 2130:0000:0000:0000:0007:0040:15bc:235f 128-bit
divised in 4 octects divised in 8 16-bit sections
193.22.33.44 (dotted-quad) 2130:0:0:0:7:40:15bc:235f
Subnetting
Each block of a column identifies a subnet, whose range of valid hosts addresses is [network address +1 — broadcast address -1] inclusive.
The network address of the subnet is the number shown inside a block.
The broadcast address of the subnet is the network address of the block underneath -1 or, for the bottom block, .255.
Network services
Well-known ports
Port number Service
20 TCP FTP (data)
21 TCP FTP (control)
22 TCP SSH
23 TCP Telnet
25 TCP SMTP
53 TCP/UDP DNS
67 UDP BOOTP/DHCP (server)
68 UDP BOOTP/DHCP (client)
80 TCP HTTP
110 TCP POP3
119 TCP NNTP
139 TCP/UDP Microsoft NetBIOS
143 TCP IMAP
161 UDP SNMP
443 TCP HTTPS
465 TCP SMTP over SSL
993 TCP IMAPS
995 TCP POP3S
1-1023: privileged ports used server-side
1024-65535: unprivileged ports used client-side
The well-known ports are listed in /etc/services
ISO/OSI TCP/IP
7 Application
6 Presentation Application HTTP, SMTP, POP, SSH, ...
5 Session
4 Transport Transport TCP, UDP, ...
3 Network Internet IPv4, IPv6, ICMP, ...
2 Data Link
Network Access Ethernet, Wi-Fi, PPP, ...
1 Physical
Network tools
dig @10.7.7.7 -t MX example.org Perform a DNS lookup for the MX record of the domain example.org,
querying nameserver 10.7.7.7
dig -x 192.0.32.8 Perform a reverse lookup on the IP address 192.0.32.8
host example.org 10.7.7.7 Perform a DNS lookup for the domain example.org, querying nameserver
10.7.7.7
whois example.org Query the WHOIS service for a Internet resource, usually a domain name
traceroute 192.0.32.8
tracepath 192.0.32.8 Print the route packets trace to a remote host
Network scanning
netstat Display network connections
netstat –-tcp Display active TCP connections
netstat -a Display all listening and non-listening sockets
netstat -n Display network connections, without resolving hostnames or portnames
netstat -p Display network connections, with PID and name of program to which
each socket belongs
netstat -i Display network interfaces
netstat -s Display protocol statistics
netstat -r Display kernel routing tables (equivalent to route -en)
nmap 192.0.32.8
nmap -sS 192.0.32.8 Scan for open ports (TCP SYN scan by default) on remote host
tcpdump ip host 10.3.3.3 tcp port 25 Sniff network packets on TCP port 25 from and to the specified host
tcpdump ether host '45:67:89:ab:cd:ef' Sniff traffic from and to the network interface with that MAC address
/etc/nsswitch.conf passwd: files nisplus nis Controls the sources used by various
shadow: files nisplus nis system library lookup functions
group: files nisplus nis
hosts: files dns nisplus nis
ifconfig eth0 10.2.3.4 netmask 255.255.255.0 broadcast 10.2.3.255 Configure IP address of eth0
ifconfig eth0 hw ether 45:67:89:ab:cd:ef Configure MAC address of eth0
dhclient
pump Request an IP address via DHCP
/etc/init.d/networking
/etc/init.d/network Initialize network services
SSH
GPG
OpenSSL
openssl x509 -text -in certif.crt -noout Read a certificate
openssl req -text -in request.csr -noout Read a Certificate Signing Request
openssl req -new -key private.key -out request.csr Generate a Certificate Signing Request for the
public key of a key pair
openssl req -new -nodes -keyout newprivate.key \ Create a 2048-bit RSA key pair and generates a
-out request.csr -newkey rsa:2048 Certificate Signing Request for it
openssl ca -config ca.conf -in request.csr \ Sign a certificate
-out certif.cer -days validity -verbose
openssl ca -config ca.conf -gencrl -revoke certif.cer \ Revoke a certificate
-crl_reason why
openssl ca -config ca.conf -gencrl -out crlist.crl Generate a Certificate Revocation List containing
all revoked certificates so far
openssl x509 -in certif.pem -outform DER \ Convert a certificate from PEM to DER
-out certif.der
openssl pkcs12 -export -in certif.pem \ Convert a certificate from PEM to PKCS#12
-inkey private.key -out certif.pfx -name friendlyname including the private key
openssl dgst -hashfunction -out file.hash file Generate the digest of a file
openssl dgst -hashfunction file | cmp -b file.hash Verify the digest of a file (if there is no output,
then digest verification is successful)
openssl dgst -hashfunction -sign private.key \ Generate the signature of a file
-out file.sig file
openssl dgst -hashfunction -verify public.key \ Verify the signature of a file
-signature file.sig file
openssl enc -e -cipher -in file -out file.enc -salt Encrypt a file
openssl enc -d -cipher -in file.enc -out file Decrypt a file
openssl genpkey -algorithm RSA -cipher 3des \ Generate a 2048-bit RSA key pair protected by
-pkeyopt rsa_keygen_bits:2048 -out key.pem TripleDES passphrase
openssl genrsa -des3 -out key.pem 2048 Generate a 2048-bit RSA key pair protected by
TripleDES passphrase (older versions of OpenSSL)
openssl pkey -text -in private.key -noout Examine a private key
openssl rsa -text -in private.key -noout Examine a private key
(older versions of OpenSSL)
openssl pkey -in old.key -out new.key -cipher Change a private key's passphrase
openssl rsa -in old.key -out new.key -cipher Change a private key's passphrase
(older versions of OpenSSL)
openssl s_client -connect www.website.com:443 > tmpfile Retrieve and inspect a certificate from a website
CTRL C
Key bindings