Linux Commands Flashcards

list of basic Linux commands

1
Q

ls

A

Lists files and directories.

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

ls -l

A

(detailed listing with permissions, owner, size)

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

ls -a

A

(show hidden files)

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

cd

A

Changes the current directory

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

cd /path/to/directory

A

(change to specified directory)

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

cd ..

A

(move up one directory level)

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

cd ~

A

(go to home directory)

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

pwd

A

Prints the current working directory.

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

mkdir

A

Creates a new directory

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

rmdir

A

Removes an empty directory

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

rm

A

Removes files or directories.

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

rm filename

A

(remove file)

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

rm -r dirname

A

(remove directory and its contents)

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

rm -f filename

A

(force remove)

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

cp

A

Copies files or directories.

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

cp -r source_dir destination_dir

A

(copy directory recursively)

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

mv

A

Moves or renames files or directories

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

cat

A

Concatenates and displays the contents of a file ex. cat filename

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

more** / **less

A

View file contents one screen at a time.
- more filename
less filename` (allows backward scrolling)

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

head

A

– Displays the first few lines of a file.
- head filename

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

tail

A

Displays the last few lines of a file.
- tail filename

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

nano / vim / vi

A

– Text editors.
- nano filename (basic editor)
- vim filename or vi filename (advanced editor)

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

chmod

A

Changes file permissions.
- chmod 755 filename

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

chown

A

Changes file ownership.
- chown user:group filename

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

chgrp

A

Changes group ownership.
- chgrp groupname filename

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

locate

A

Quickly finds files by name (needs updated database).
- locate filename

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

which

A

Shows the full path of shell commands.
- which command_name

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

tar

A

Archives and extracts files.
- tar -cvf archive.tar /path (create archive)
- tar -xvf archive.tar (extract archive)
- tar -czvf archive.tar.gz /path (create compressed archive)
- tar -xzvf archive.tar.gz (extract compressed archive

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

gzip / gunzip

A

Compresses and decompresses files.
- gzip filename
- gunzip filename.gz

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

zip / unzip

A

Creates and extracts zip files.
- zip archive.zip filename
- unzip archive.zip

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

grep

A

Searches for patterns in files.
- grep "pattern" filename

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

find

A

Searches for files in a directory hierarchy.
- find /path -name "filename"

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

netstat** / **ss`**

A

Displays network connections, routing tables, and interface statistics.
- ss (modern replacement for netstat)

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

wget

A

Downloads files from the web.
- wget http://example.com/file

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

curl

A

Transfers data from or to a server.
- curl http://example.com

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

ip a

A

Displays network configuration.
- ip a (preferred over ifconfig on newer systems)

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

ps

A

Displays currently running processes.
- ps aux (all running processes)

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

top / htop

A

Shows running processes and resource usage.
- top (real-time view)
- htop (colorful and interactive, may need installation)

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

free

A

Displays memory usage.
- free -h (human-readable format)

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

du

A

– Shows disk usage of files and directories.
- du -sh (summary of current directory)

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

df

A

– Shows disk usage of file systems.
- df -h (human-readable format)

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

uname

A

Displays system information.
- uname -a (detailed system info)

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

adduser / useradd

A

Adds a new user to the system.

adduser username (interactive and simpler)
useradd username (manual setup)

44
Q

deluser / userdel

A

Deletes a user from the system.

deluser username
userdel username

45
Q

usermod

A

Modifies a user’s account.

usermod -aG groupname username (add user to a group)

46
Q

passwd

A

Changes a user’s password. passwd username

47
Q

groups

A

Displays the groups a user is in.

groups username

48
Q

id

A

Shows user and group IDs for the current user or specified user.

id username

49
Q

chage

A

Changes user password expiration information.

chage -l username (list expiration info)

50
Q

newgrp

A

Logs in to a new group.

51
Q

umask

A

Sets the default permission for new files.

52
Q

kill

A

Terminates a process by PID.

kill PID

53
Q

killall

A

Kills all processes by name.

killall process_name

54
Q

systemctl

A

Controls the system’s services and daemons.

systemctl start service_name
systemctl stop service_name
systemctl status service_name
systemctl enable service_name (enable at boot)
systemctl disable service_name

55
Q

service

A

Manages services (older systems).

service service_name start
service service_name stop

56
Q

nice / renice

A

Adjusts the priority of processes.

nice -n priority command
renice priority PID

57
Q

fdisk

A

Partition a hard drive.

fdisk /dev/sdX

58
Q

mount

A

Mounts a file system.

mount /dev/sdX /mount/point

59
Q

umount

A

Unmounts a file system.

umount /dev/sdX

60
Q

lsblk

A

Lists information about block devices.

lsblk

61
Q

blkid

A

Identifies the UUID and type of a filesystem.

62
Q

fsck

A

Checks and repairs file systems.

fsck /dev/sdX

63
Q

rsync

A

Synchronizes files between locations.

rsync -avz /source/ /destination/

64
Q

dd

A

Copies and converts files, often used for creating disk images.

dd if=/dev/sdX of=/path/to/image.img

65
Q

traceroute

A

Traces the route packets take to a network host.

traceroute hostname_or_IP

66
Q

nslookup / dig

A

Queries DNS for domain name information.

nslookup domain_name
dig domain_name

67
Q

iptables

A

Configures IP packet filter rules for firewalling.

iptables -L (list current rules)
iptables -A (add a rule)

68
Q

firewalld

A

Manages firewall dynamically.

firewall-cmd –state (check firewall status)
firewall-cmd –permanent –add-port=8080/tcp

69
Q

nmap

A

Scans networks and services.

nmap hostname_or_IP

70
Q

hostnamectl

A

Set or display the system’s hostname.

71
Q

scp

A

Securely copies files over the network.

scp file user@remote:/path

72
Q

ssh

A

Securely logs into a remote machine.

ssh user@hostname_or_IP

73
Q

curl

A

Transfers data to/from a server.

curl http://example.com

74
Q

sudo

A

Executes a command with superuser privileges.

sudo command

75
Q

ufw

A

Simplified firewall tool (for iptables).

ufw status
ufw allow 22/tcp
ufw enable

76
Q

fail2ban

A

Bans IPs with failed login attempts (usually needs to be installed).

fail2ban-client status
fail2ban-client unban IP

77
Q

last

A

Displays the last login history.

78
Q

who

A

Shows who is logged into the system.

79
Q

history

A

Shows the command history for the current user.

80
Q

auditd

A

Auditing daemon for security monitoring (audit logs)

81
Q

selinux

A

Security-Enhanced Linux status and control (if enabled).

getenforce (check mode)
setenforce 0 (disable SELinux temporarily)

82
Q

tcpdump

A

Captures and analyzes network packets.

tcpdump -i eth0

83
Q

dmesg

A

Displays kernel ring buffer messages (hardware-related logs).

84
Q

uptime

A

Shows how long the system has been running and the load averages.

85
Q

reboot / shutdown

A

Reboots or shuts down the system.

reboot
shutdown -h now

86
Q

crontab

A

Schedules tasks (cron jobs).

crontab -e (edit cron jobs)

87
Q

at

A

Schedules one-time tasks.

at now + 5 minutes

88
Q

timedatectl

A

Manages system time and date.

timedatectl

89
Q

ip link

A

Manages network interfaces.

ip link show (list all interfaces)
ip link set eth0 up (bring up an interface)
ip link set eth0 down (bring down an interface)

90
Q

ethtool

A

Displays or changes network interface card (NIC) settings.

ethtool eth0 (show NIC settings)

91
Q

nmcli

A

Manages network connections (used with NetworkManager).

nmcli device status (show status of all devices)
nmcli connection show (list saved network connections)
nmcli connection up “connection_name” (activate a connection)

92
Q

iwconfig

A

Shows or configures wireless network interfaces (for wireless devices).iwconfig (show wireless interface status)

93
Q

ifup / ifdown

A

Brings a network interface up or down (older systems).

ifup eth0 (bring up interface)
ifdown eth0 (bring down interface)

94
Q

netstat / ss

A

Displays network connections, routing tables, and interface statistics.

netstat -tuln (list all listening ports)
ss -tuln (modern replacement for netstat)

95
Q

nmap

A

Scans networks and discovers open ports.

nmap -sP 192.168.1.0/24 (ping scan to detect live hosts in a subnet)
nmap -p 22 192.168.1.1 (scan port 22 on a specific host)

96
Q

mtr

A

Combines ping and traceroute to diagnose network issues.

mtr google.com

97
Q

nc / netcat

A

Network utility for reading/writing data over TCP/UDP.

nc -zv 192.168.1.1 22 (check if port 22 is open on the host)

98
Q

arp

A

Shows or modifies the system’s ARP (Address Resolution Protocol) table.

arp -a (display ARP table)
arp -d 192.168.1.1 (delete ARP entry)

99
Q

iptables

A

Manages IPv4 packet filtering rules.

iptables -L (list rules)
iptables -A INPUT -p tcp –dport 22 -j ACCEPT (allow incoming SSH traffic)
iptables -A INPUT -p tcp –dport 80 -j DROP (block incoming HTTP traffic)

100
Q

firewall-cmd

A

Controls the firewall (for systems using firewalld).

firewall-cmd –list-all (show all firewall rules)
firewall-cmd –add-port=8080/tcp –permanent (open port 8080)
firewall-cmd –reload (reload firewall rules)

101
Q

ufw

A

Simplified firewall tool (for Ubuntu/Debian-based systems).

ufw status (check firewall status)
ufw allow 22 (allow SSH traffic)
ufw enable (enable firewall)

102
Q

host

A

Performs DNS lookups.

host google.com

103
Q

nload

A

Shows network traffic and bandwidth usage.

nload eth0

104
Q

vnstat

A

Monitors network traffic usage statistics over time.

vnstat (show traffic statistics for all interfaces)
vnstat -i eth0 (show traffic statistics for a specific interface)

105
Q

Timothy is a system admin, and his work involves complex knowledge of executables and
shared libraries in Linux. There are several commands that he uses often; which one does he
use to access shared object dependencies?
A. tar
B. zip
C. ldd
D. uname -a

A

C. The man page explains ldd as printing the shared objects (shared libraries) required by
each program or shared object specified on the command line. The command tar is used to
work with tarballs (or files compressed in a tarball archive) in the Linux command line. You
can use the command zip to compress files into a zip archive, and use unzip to extract
files from a zip archive. Use uname to display information about the system your Linux
distro is running. Using the command uname -a
prints most of the information about the
system. It prints the kernel release date, version, processor type, and more.