ECM 1413 Linux commands Flashcards
ls
list files and directories
ls options
-l: Long format listing
-a: Include hidden files
-h: Human-readable files
cd
change directory
pwd
Print current working directory
mkdir
make new directory
rm
Remove files and directories
rm options
-r: Remove directories recursively
-f: Force removal without confirmation
cp
copy files and directories
(-r to copy recursively)
mv
move/rename files and directories
touch
create an empty file or update file timestamps
cat
view the contents of a file
head
Display the first few lines of a file
-n to specify the number of lines to display
tail
Display the last few lines of a file
-n to specify the number
ln
create links between files
-s to create a soft link (hard by default)
find
search for files and directories
-name to search by file name
-type to search by file type
chmod
change file permissions
u: user/owner permissions
g: group permissions
o: other permissions
+: add permissions
-: remove permissions
=: set permissions explicitly
chown
change file ownership
chgrp
change group ownership
unmask
set default file permissions
tar
create or extract archive files
-c: create a new archive
-x: Extract files from an archive
-f: Specify the archive file name
-v: verbose mode
-z: compress the archive with gzip
-j: compress the archive with bzip2
gzip
compress files
-d: Decompress files
zip
Create compressed zip archives
-r: Recursively include directories
ps
Display running processes
-aux: Show all processes
top
Monitor system processes in real-time
kill
Terminate a process
-9: Forcefully kill a process
pkill
terminate processes based on name
pgrep
List processes based on their name
grep
used to search for specific patterns or regular expressions in text files or streams and display matching lines.
*
wildcard equating to 0 or more characters
?
wildcard equating to exactly 1 character
[]
wildcard. Matches any one of the enclosed characters in the [].
[a-z]
wildcard. Matches any one of the enclosed characters in the [] in a specified range.
{}
wildcard equating to any of the comma-separated characters in the {}