Linux Command Line Flashcards

1
Q

uname -a

A

Display Linux system information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

uname -r

A

Display kernel release information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

cat /etc/redhat-release

A

Show which version of Red Hat installed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

lsb_release -a

A

Show which version of Ubuntu installed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

uptime

A

Show how long the system has been running + load

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

hostname

A

Show system host name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

hostname -I

A

Display all local IP addresses of the host

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

last reboot

A

Show system reboot history

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

date

A

Show the current date and time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

cal

A

Show this month’s calendar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

w

A

Display who is online

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

whoami

A

Who you are logged in as

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

dmesg

A

Display messages in kernel ring buffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

cat /proc/cpuinfo

A

Display CPU information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

cat /proc/meminfo

A

Display memory information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

free -h

A

Display free and used memory ( -h for human readable, -m for MB, -g for GB.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

lspci -tv

A

Display PCI devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

lsusb -tv

A

Display USB devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

dmidecode

A

Display DMI/SMBIOS (hardware info) from the BIOS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

hdparm -i /dev/sda

A

Show info about disk sda

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

hdparm -tT /dev/sda

A

Perform a read speed test on disk sda

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

lshw

A

Display information about CPU, memory, storage, and network interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

lsblk

A

Display information about all storage devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

top

A

Display and manage the top processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
htop
Interactive process viewer (top alternative)
26
mpstat 1
Display processor related statistics
27
vmstat 1
Display virtual memory statistics
28
iostat 1
Display I/O statistics
29
tail -100 /var/log/messages
Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.)
30
tcpdump -i eth0
Capture and display all packets on interface eth0
31
tcpdump -i eth0 'port 80'
Monitor all traffic on port 80 (HTTP)
32
lsof
List all open files on the system
33
lsof -u user
List files opened by user
34
free -h
Display free and used memory (-h for human readable, -m for MB, -g for GB.)
35
watch df -h
Execute "df-h", showing periodic updates
36
mpstat
Display statistics about CPU usage
37
pidstat
Display statistics about processes running
38
id
Display the user and group ids of your current user
39
last
Display the last users who have logged onto the system
40
who
Show who is logged into the system
41
w
Show who is logged in and what they are doing
42
groupadd test
Create a group name "test".
43
useradd -c "John Smith" -m john
Create an account named john, with a comment of "John Smith" and create the user home directory
44
userdel john
Delete the john account
45
usermod -aG sales john
Add the john account to the sales group
46
ls -al
List all files in a long listing (detailed) format
47
pwd
Display the present working directory
48
mkdir directory
Create a directory
49
rm file
Remove (delete) file
50
rm -r directory
Remove the directory and its contents recursively
51
rm -f file
Force removal of file without prompting for confirmation
52
rm -rf directory
Forcefully remove directory recursively
53
cp file1 file2
Copy file1 to file2
54
cp -r source_directory destination
Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with contents of source_directory
55
mv file1 file2
Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
56
ln -s /path/to/file linkname
Create symbolic link to linkname
57
touch file
Create an empty file or update the access and modification times of file
58
cat file
View the contents of file
59
less file
Browse through a text file
60
head file
Display the first 10 lines of file
61
tail file
Display the last 10 lines of file
62
tail -f file
Display the last 10 lines of file and "follow" the file as it grows
63
ps
Display your currently running processes
64
ps -ef
Display all the currently running processes on the system
65
ps -ef l grep processname
Display process information for processname
66
top
Display and manage the top processes
67
htop
Interactive process viewer (top alternative)
68
kill pid
Kill process with process ID of pid
69
killall processname
Kill all processes named processname
70
program &
Start program in the background
71
bg
Display stopped or background jobs
72
fg
Brings the most recent background job to foreground
73
fg n
Brings job n to the foreground
74
nohup processname
Runs a process even after user logs out
75
chown john /path/to/file
Change ownership /path/to/file to john
76
chgrp sales /path/to/file
Change group ownership of /path/to/file to group sales
77
ip a
Display all network interfaces and IP address
78
ip addr show dev eth0
Display eth0 address and details
79
ethtool eth0
Query or control network driver and hardware settings
80
ping host
Send ICMP echo request to host
81
whois domain
Display whois information for domain
82
dig domain
Display DNS information for domain
83
dig -x IP_ADDRESS
Reverse lookup of IP_ADDRESS
84
host domain
Display DNS IP address for domain
85
hostname -i
Display the network address of the host name
86
hostname -I
Display all local IP addresses of the host
87
wget http://domain.com/file
Download http://domain.com/file
88
netstat -nutlp
Display listening tcp and udp ports and corresponding programs
89
ifconfig
Display information about network interfaces
90
traceroute host
Display the path that packets take to host
91
tcpdump
Capture and analyze network traffic
92
tar cf archive.tar directory
Create tar name archive.tar containing directory
93
tar xf archive.tar
Extract the contents from archive.tar
94
tar czf archive.tar.gz directory
Create a gzip compressed tar file name archive.tar.gz
95
tar xzf archive.tar.gz
Extract a gzip compressed tar file
96
tar cjf archive.tar.bz2 directory
Create a tar file with bzip2 compression
97
tar xjf archive.tar.bz2
Extract a bzip2 compressed tar file
98
yum search keyword
Search for a package by keyword
99
yum install package
install package
100
yum info package
Display description and summary information about package for RHEL based systems
101
rpm -i package.rpm
Install package from local file named package.rpm
102
yum remove package
Remove/uninstall package for RHEL based systems.
103
yum update package
Update package with name package for RHEL based systmes
104
tar zxvf sourcecode.tar.gz cd sourcecode./configure make make install
Install software from source code
105
apt-get update
Update package list for Debian based systems
106
apt-get upgrade
Upgrade all installed packages to their newest version for Debian based systems
107
apt-get install package
Install package with name package for Debian based systems
108
apt-remove package
Remove package with name package for Debian based systems
109
grep pattern file
Search for pattern in file
110
grep -r pattern directory
Search recursively for pattern in directory
111
locate name
Find files and directories by name
112
find /home/john -name 'prefix*'
find files in /home/john that start with "prefix".
113
find /home -size +100M
Find files larger than 100MB in /home
114
whereis program
Display the location of the binary, source and manual page files of program
115
which program
Display the path of executable that would run if program is executed
116
ssh host
Connect to host as your local username
117
ssh user@host
Connect to host as user
118
ssh -port user@host
Connect to host using port
119
ssh-keygen
Create a new SSH key pair
120
ssh-copy-id user@host
Copy SSH key to the remote host to enable passwordless logins for user
121
scp file.txt server:/tmp
Secure copy file.txt to the /tmp folder on server
122
scp server: /var/www/*.html/tmp
Copy *.html files from server to the local /tmp folder
123
scp -r server:/var/www /tmp
Copy all files and directories recursively from server to the current system's /tmp folder
124
rsync -a /home /backups/
Synchronize /home to /backups/home
125
rsync -avz /home server:/backups/
Synchronize files/directories between the local and remote system with compression enabled
126
ftp host
Connect to FTP server on the remote host
127
df -h
Show free and used space on mounted filesystems
128
df -i
Show free and used inodes on mounted filesystems
129
fdisk -l
Display disks partitions sizes and types
130
du -ah
Display disk usage for all files and directories in human readable format
131
du -sh
Display total disk usage off the current directory
132
du -a directory
Display size of all files directory
133
findmnt
List all mounted file systems with details
134
cd ..
To go up one level of the directory tree. (Change into the parent directory.)
135
cd
Go to the $HOME directory
136
cd /etc
Change to the /etc directory
137
alias goto='cd /etc/'
Create goto alias for command cd /etc/
138
passwd
Change the current user's password
139
sudo -i
Switch to the root account with root's environment (Login shell.)
140
sudo -s
Execute your current shell as root (Non-login shell.)
141
sudo -l
List sudo privileges for the current user
142
visudo
Edit the sudoers configuration file
143
getenforce
Display the current SELinux mode
144
sestatus
Display SELinu details such as the current SELinux mode, the configured mode, and loaded policy
145
setenforce 0
Change the current SELinux mode to Permissive. (Does not survive a reboot.)
146
setenforce 1
Change the current SELinux mode to Enforcing. (Does not survive a reboot.)
147
SELINUX=enforcing
Set the SELinux mode to enforcing on boot by using this setting in the /etc/seliux/configfile
148
SELINUX=permissive
Set the SELinux mode to permissive on boot by using this setting in /etc/selinux/configfile
149
SELINUX=disabled
Set the SELinux mode to disabled on boot by using this setting in the /etc/selinux/configfile
150
dmesg
Display messages in kernel ring buffer
151
jounalctl
Display logs stored in the systemd journal
152
jounalctl -u servicename
Display logs for a specific unit (service).