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
chgrp
Changes group ownership. - `chgrp groupname filename`
26
locate
Quickly finds files by name (needs updated database). - `locate filename`
27
which
Shows the full path of shell commands. - `which command_name`
28
**`tar`**
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
29
**`gzip`** / **`gunzip`**
Compresses and decompresses files. - `gzip filename` - `gunzip filename.gz`
30
**`zip`** / **`unzip`**
Creates and extracts zip files. - `zip archive.zip filename` - `unzip archive.zip`
31
grep
Searches for patterns in files. - `grep "pattern" filename`
32
find
Searches for files in a directory hierarchy. - `find /path -name "filename"`
33
netstat`** / **`ss`**
Displays network connections, routing tables, and interface statistics. - `ss` (modern replacement for `netstat`)
34
wget
Downloads files from the web. - `wget http://example.com/file`
35
curl
Transfers data from or to a server. - `curl http://example.com`
36
ip a
Displays network configuration. - `ip a` (preferred over `ifconfig` on newer systems)
37
ps
Displays currently running processes. - `ps aux` (all running processes)
38
top / htop
Shows running processes and resource usage. - `top` (real-time view) - `htop` (colorful and interactive, may need installation)
39
free
Displays memory usage. - `free -h` (human-readable format)
40
du
– Shows disk usage of files and directories. - `du -sh` (summary of current directory)
41
df
– Shows disk usage of file systems. - `df -h` (human-readable format)
42
uname
Displays system information. - `uname -a` (detailed system info)
43
adduser / useradd
Adds a new user to the system. adduser username (interactive and simpler) useradd username (manual setup)
44
deluser / userdel
Deletes a user from the system. deluser username userdel username
45
usermod
Modifies a user's account. usermod -aG groupname username (add user to a group)
46
passwd
Changes a user's password. passwd username
47
groups
Displays the groups a user is in. groups username
48
id
Shows user and group IDs for the current user or specified user. id username
49
chage
Changes user password expiration information. chage -l username (list expiration info)
50
newgrp
Logs in to a new group.
51
umask
Sets the default permission for new files.
52
kill
Terminates a process by PID. kill PID
53
killall
Kills all processes by name. killall process_name
54
systemctl
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
service
Manages services (older systems). service service_name start service service_name stop
56
nice / renice
Adjusts the priority of processes. nice -n priority command renice priority PID
57
fdisk
Partition a hard drive. fdisk /dev/sdX
58
mount
Mounts a file system. mount /dev/sdX /mount/point
59
umount
Unmounts a file system. umount /dev/sdX
60
lsblk
Lists information about block devices. lsblk
61
blkid
Identifies the UUID and type of a filesystem.
62
fsck
Checks and repairs file systems. fsck /dev/sdX
63
rsync
Synchronizes files between locations. rsync -avz /source/ /destination/
64
dd
Copies and converts files, often used for creating disk images. dd if=/dev/sdX of=/path/to/image.img
65
traceroute
Traces the route packets take to a network host. traceroute hostname_or_IP
66
nslookup / dig
Queries DNS for domain name information. nslookup domain_name dig domain_name
67
iptables
Configures IP packet filter rules for firewalling. iptables -L (list current rules) iptables -A (add a rule)
68
firewalld
Manages firewall dynamically. firewall-cmd --state (check firewall status) firewall-cmd --permanent --add-port=8080/tcp
69
nmap
Scans networks and services. nmap hostname_or_IP
70
hostnamectl
Set or display the system's hostname.
71
scp
Securely copies files over the network. scp file user@remote:/path
72
ssh
Securely logs into a remote machine. ssh user@hostname_or_IP
73
curl
Transfers data to/from a server. curl http://example.com
74
sudo
Executes a command with superuser privileges. sudo command
75
ufw
Simplified firewall tool (for iptables). ufw status ufw allow 22/tcp ufw enable
76
fail2ban
Bans IPs with failed login attempts (usually needs to be installed). fail2ban-client status fail2ban-client unban IP
77
last
Displays the last login history.
78
who
Shows who is logged into the system.
79
history
Shows the command history for the current user.
80
auditd
Auditing daemon for security monitoring (audit logs)
81
selinux
Security-Enhanced Linux status and control (if enabled). getenforce (check mode) setenforce 0 (disable SELinux temporarily)
82
tcpdump
Captures and analyzes network packets. tcpdump -i eth0
83
dmesg
Displays kernel ring buffer messages (hardware-related logs).
84
uptime
Shows how long the system has been running and the load averages.
85
reboot / shutdown
Reboots or shuts down the system. reboot shutdown -h now
86
crontab
Schedules tasks (cron jobs). crontab -e (edit cron jobs)
87
at
Schedules one-time tasks. at now + 5 minutes
88
timedatectl
Manages system time and date. timedatectl
89
ip link
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
ethtool
Displays or changes network interface card (NIC) settings. ethtool eth0 (show NIC settings)
91
nmcli
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
iwconfig
Shows or configures wireless network interfaces (for wireless devices).iwconfig (show wireless interface status)
93
ifup / ifdown
Brings a network interface up or down (older systems). ifup eth0 (bring up interface) ifdown eth0 (bring down interface)
94
netstat / ss
Displays network connections, routing tables, and interface statistics. netstat -tuln (list all listening ports) ss -tuln (modern replacement for netstat)
95
nmap
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
mtr
Combines ping and traceroute to diagnose network issues. mtr google.com
97
nc / netcat
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
arp
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
iptables
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
firewall-cmd
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
ufw
Simplified firewall tool (for Ubuntu/Debian-based systems). ufw status (check firewall status) ufw allow 22 (allow SSH traffic) ufw enable (enable firewall)
102
host
Performs DNS lookups. host google.com
103
nload
Shows network traffic and bandwidth usage. nload eth0
104
vnstat
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
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
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.