Linux Commands 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

badblocks -s /dev/sda

A

Test for unreadable blocks on disk sda

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
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
24
Q

lsblk

A

Display information about all storage devices

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