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
Q

htop

A

Interactive process viewer (top alternative)

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

mpstat 1

A

Display processor related statistics

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

vmstat 1

A

Display virtual memory statistics

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

iostat 1

A

Display I/O statistics

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

tail -100 /var/log/messages

A

Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.)

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

tcpdump -i eth0

A

Capture and display all packets on interface eth0

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

tcpdump -i eth0 ‘port 80’

A

Monitor all traffic on port 80 (HTTP)

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

lsof

A

List all open files on the system

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

lsof -u user

A

List files opened by user

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

watch df -h

A

Execute “df-h”, showing periodic updates

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

mpstat

A

Display statistics about CPU usage

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

pidstat

A

Display statistics about processes running

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

id

A

Display the user and group ids of your current user

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

last

A

Display the last users who have logged onto the system

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

who

A

Show who is logged into the system

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

w

A

Show who is logged in and what they are doing

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

groupadd test

A

Create a group name “test”.

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

useradd -c “John Smith” -m john

A

Create an account named john, with a comment of “John Smith” and create the user home directory

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

userdel john

A

Delete the john account

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

usermod -aG sales john

A

Add the john account to the sales group

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

ls -al

A

List all files in a long listing (detailed) format

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

pwd

A

Display the present working directory

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

mkdir directory

A

Create a directory

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

rm file

A

Remove (delete) file

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

rm -r directory

A

Remove the directory and its contents recursively

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

rm -f file

A

Force removal of file without prompting for confirmation

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

rm -rf directory

A

Forcefully remove directory recursively

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

cp file1 file2

A

Copy file1 to file2

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

cp -r source_directory destination

A

Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with contents of source_directory

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

mv file1 file2

A

Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2

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

ln -s /path/to/file linkname

A

Create symbolic link to linkname

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

touch file

A

Create an empty file or update the access and modification times of file

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

cat file

A

View the contents of file

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

less file

A

Browse through a text file

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

head file

A

Display the first 10 lines of file

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

tail file

A

Display the last 10 lines of file

62
Q

tail -f file

A

Display the last 10 lines of file and “follow” the file as it grows

63
Q

ps

A

Display your currently running processes

64
Q

ps -ef

A

Display all the currently running processes on the system

65
Q

ps -ef l grep processname

A

Display process information for processname

66
Q

top

A

Display and manage the top processes

67
Q

htop

A

Interactive process viewer (top alternative)

68
Q

kill pid

A

Kill process with process ID of pid

69
Q

killall processname

A

Kill all processes named processname

70
Q

program &

A

Start program in the background

71
Q

bg

A

Display stopped or background jobs

72
Q

fg

A

Brings the most recent background job to foreground

73
Q

fg n

A

Brings job n to the foreground

74
Q

nohup processname

A

Runs a process even after user logs out

75
Q

chown john /path/to/file

A

Change ownership /path/to/file to john

76
Q

chgrp sales /path/to/file

A

Change group ownership of /path/to/file to group sales

77
Q

ip a

A

Display all network interfaces and IP address

78
Q

ip addr show dev eth0

A

Display eth0 address and details

79
Q

ethtool eth0

A

Query or control network driver and hardware settings

80
Q

ping host

A

Send ICMP echo request to host

81
Q

whois domain

A

Display whois information for domain

82
Q

dig domain

A

Display DNS information for domain

83
Q

dig -x IP_ADDRESS

A

Reverse lookup of IP_ADDRESS

84
Q

host domain

A

Display DNS IP address for domain

85
Q

hostname -i

A

Display the network address of the host name

86
Q

hostname -I

A

Display all local IP addresses of the host

87
Q

wget http://domain.com/file

A

Download http://domain.com/file

88
Q

netstat -nutlp

A

Display listening tcp and udp ports and corresponding programs

89
Q

ifconfig

A

Display information about network interfaces

90
Q

traceroute host

A

Display the path that packets take to host

91
Q

tcpdump

A

Capture and analyze network traffic

92
Q

tar cf archive.tar directory

A

Create tar name archive.tar containing directory

93
Q

tar xf archive.tar

A

Extract the contents from archive.tar

94
Q

tar czf archive.tar.gz directory

A

Create a gzip compressed tar file name archive.tar.gz

95
Q

tar xzf archive.tar.gz

A

Extract a gzip compressed tar file

96
Q

tar cjf archive.tar.bz2 directory

A

Create a tar file with bzip2 compression

97
Q

tar xjf archive.tar.bz2

A

Extract a bzip2 compressed tar file

98
Q

yum search keyword

A

Search for a package by keyword

99
Q

yum install package

A

install package

100
Q

yum info package

A

Display description and summary information about package for RHEL based systems

101
Q

rpm -i package.rpm

A

Install package from local file named package.rpm

102
Q

yum remove package

A

Remove/uninstall package for RHEL based systems.

103
Q

yum update package

A

Update package with name package for RHEL based systmes

104
Q

tar zxvf sourcecode.tar.gz cd sourcecode./configure
make
make install

A

Install software from source code

105
Q

apt-get update

A

Update package list for Debian based systems

106
Q

apt-get upgrade

A

Upgrade all installed packages to their newest version for Debian based systems

107
Q

apt-get install package

A

Install package with name package for Debian based systems

108
Q

apt-remove package

A

Remove package with name package for Debian based systems

109
Q

grep pattern file

A

Search for pattern in file

110
Q

grep -r pattern directory

A

Search recursively for pattern in directory

111
Q

locate name

A

Find files and directories by name

112
Q

find /home/john -name ‘prefix*’

A

find files in /home/john that start with “prefix”.

113
Q

find /home -size +100M

A

Find files larger than 100MB in /home

114
Q

whereis program

A

Display the location of the binary, source and manual page files of program

115
Q

which program

A

Display the path of executable that would run if program is executed

116
Q

ssh host

A

Connect to host as your local username

117
Q

ssh user@host

A

Connect to host as user

118
Q

ssh -port user@host

A

Connect to host using port

119
Q

ssh-keygen

A

Create a new SSH key pair

120
Q

ssh-copy-id user@host

A

Copy SSH key to the remote host to enable passwordless logins for user

121
Q

scp file.txt server:/tmp

A

Secure copy file.txt to the /tmp folder on server

122
Q

scp server: /var/www/*.html/tmp

A

Copy *.html files from server to the local /tmp folder

123
Q

scp -r server:/var/www /tmp

A

Copy all files and directories recursively from server to the current system’s /tmp folder

124
Q

rsync -a /home /backups/

A

Synchronize /home to /backups/home

125
Q

rsync -avz /home server:/backups/

A

Synchronize files/directories between the local and remote system with compression enabled

126
Q

ftp host

A

Connect to FTP server on the remote host

127
Q

df -h

A

Show free and used space on mounted filesystems

128
Q

df -i

A

Show free and used inodes on mounted filesystems

129
Q

fdisk -l

A

Display disks partitions sizes and types

130
Q

du -ah

A

Display disk usage for all files and directories in human readable format

131
Q

du -sh

A

Display total disk usage off the current directory

132
Q

du -a directory

A

Display size of all files directory

133
Q

findmnt

A

List all mounted file systems with details

134
Q

cd ..

A

To go up one level of the directory tree. (Change into the parent directory.)

135
Q

cd

A

Go to the $HOME directory

136
Q

cd /etc

A

Change to the /etc directory

137
Q

alias goto=’cd /etc/’

A

Create goto alias for command cd /etc/

138
Q

passwd

A

Change the current user’s password

139
Q

sudo -i

A

Switch to the root account with root’s environment (Login shell.)

140
Q

sudo -s

A

Execute your current shell as root (Non-login shell.)

141
Q

sudo -l

A

List sudo privileges for the current user

142
Q

visudo

A

Edit the sudoers configuration file

143
Q

getenforce

A

Display the current SELinux mode

144
Q

sestatus

A

Display SELinu details such as the current SELinux mode, the configured mode, and loaded policy

145
Q

setenforce 0

A

Change the current SELinux mode to Permissive. (Does not survive a reboot.)

146
Q

setenforce 1

A

Change the current SELinux mode to Enforcing. (Does not survive a reboot.)

147
Q

SELINUX=enforcing

A

Set the SELinux mode to enforcing on boot by using this setting in the /etc/seliux/configfile

148
Q

SELINUX=permissive

A

Set the SELinux mode to permissive on boot by using this setting in /etc/selinux/configfile

149
Q

SELINUX=disabled

A

Set the SELinux mode to disabled on boot by using this setting in the /etc/selinux/configfile

150
Q

dmesg

A

Display messages in kernel ring buffer

151
Q

jounalctl

A

Display logs stored in the systemd journal

152
Q

jounalctl -u servicename

A

Display logs for a specific unit (service).