Linux Commands Flashcards
list of basic Linux commands
ls
Lists files and directories.
ls -l
(detailed listing with permissions, owner, size)
ls -a
(show hidden files)
cd
Changes the current directory
cd /path/to/directory
(change to specified directory)
cd ..
(move up one directory level)
cd ~
(go to home directory)
pwd
Prints the current working directory.
mkdir
Creates a new directory
rmdir
Removes an empty directory
rm
Removes files or directories.
rm filename
(remove file)
rm -r dirname
(remove directory and its contents)
rm -f filename
(force remove)
cp
Copies files or directories.
cp -r source_dir destination_dir
(copy directory recursively)
mv
Moves or renames files or directories
cat
Concatenates and displays the contents of a file ex. cat filename
more** / **
less
View file contents one screen at a time.
- more filename
less filename` (allows backward scrolling)
head
– Displays the first few lines of a file.
- head filename
tail
Displays the last few lines of a file.
- tail filename
nano
/ vim
/ vi
– Text editors.
- nano filename
(basic editor)
- vim filename
or vi filename
(advanced editor)
chmod
Changes file permissions.
- chmod 755 filename
chown
Changes file ownership.
- chown user:group filename
chgrp
Changes group ownership.
- chgrp groupname filename
locate
Quickly finds files by name (needs updated database).
- locate filename
which
Shows the full path of shell commands.
- which command_name
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
gzip
/ gunzip
Compresses and decompresses files.
- gzip filename
- gunzip filename.gz
zip
/ unzip
Creates and extracts zip files.
- zip archive.zip filename
- unzip archive.zip
grep
Searches for patterns in files.
- grep "pattern" filename
find
Searches for files in a directory hierarchy.
- find /path -name "filename"
netstat** / **
ss`**
Displays network connections, routing tables, and interface statistics.
- ss
(modern replacement for netstat
)
wget
Downloads files from the web.
- wget http://example.com/file
curl
Transfers data from or to a server.
- curl http://example.com
ip a
Displays network configuration.
- ip a
(preferred over ifconfig
on newer systems)
ps
Displays currently running processes.
- ps aux
(all running processes)
top / htop
Shows running processes and resource usage.
- top
(real-time view)
- htop
(colorful and interactive, may need installation)
free
Displays memory usage.
- free -h
(human-readable format)
du
– Shows disk usage of files and directories.
- du -sh
(summary of current directory)
df
– Shows disk usage of file systems.
- df -h
(human-readable format)
uname
Displays system information.
- uname -a
(detailed system info)