Linux commands Flashcards
Print the current working directory.
pwd
Change the directory
cd /path/to/directory
List files and directories in the current directory (list)
ls -l
List files and directories in the current directory (hidden)
ls -a
Create a new empty file
touch [filename]
Copy files
cp source_file destination_file
Remove files
rm [filename]
Move or rename files or directories.
mv source destination
View the contents of a file.
cat [filename]
Create a new directory.
mkdir [directory_name]
Open the file in the text editor.
nano filename
Removes directories
rm -r [directory_name]
Copies directories
cp -r
Searches for patterns within files.
grep ‘pattern’ filename
Modifies the permissions of files or directories
chmod permissions filename
Changes the owner and/or group of files or directories.
chown owner:group filename
Shows the amount of disk space used and available on file systems.
df -h
Searches for files and directories in a directory hierarchy.
find /path/to/search -name filename
Prints text or variables to the terminal.
echo [text]
Shows the first few lines of a file (default is 10 lines).
head [filename]
Shows the last few lines of a file (default is 10 lines).
tail [filename]
Sorts the lines of a text file alphabetically
sort [filename]
Runs commands with elevated privileges (as a superuser)
sudo [command]
Sorts the lines of a text file numerically
sort -n [filename]
Display Running Processes
ps
Terminate Processes
kill [pid]
Check Disk Usage of Files/Directories
du [directory]
Monitor System Processes
top
List Information About Block Devices
lsblk
Displays the number of lines, words, and characters in a file.
wc filename.txt
Lists files in the directory sorted by modification time, in reverse order (oldest to newest).
ls -ltr
Allows you to view the contents of a file one screen at a time.
less filename.txt
It shows the list of commands you’ve previously executed.
history
Shows the manual (documentation) for a given command.
man [command]