ls
command output.ls -a
option lists all files, including hidden ones.ls
: Lists files and directories.ls -l
: Provides a long listing with details like permissions, owner, size, and modification date.ls -a
: Lists all files, including hidden ones.cd
: Changes the current directory.cd
(without arguments): Returns to the home directory.rm
: Removes (deletes) files.rm -r
: Recursively removes directories and their contents (dangerous!).rmdir
: Removes empty directories.cp
: Copies files.mv
: Moves files.find
: Finds files based on various criteria.ln
: Creates links (hard or symbolic).ls -l
shows file type, permissions, owner, group, size, and date.pwd
shows the current working directory.mv bad.html good.html
renames bad.html
to good.html
.cp good.html bad.html
creates a copy of good.html
named bad.html
.*
: Matches any sequence of zero or more characters.?
: Matches a single character.[]
: Matches any of the characters listed inside the brackets.ls /usr/bin/*zip
: Shows all files in /usr/bin/
that end with "zip".ls /usr/bin/??zip
: Shows files in /usr/bin/
that have two characters followed by "zip"..
denotes the current directory...
denotes the parent directory.~
denotes the user's home directory./home/u123456/file1.txt
and the current directory /home/u123456/csc1030
:/home/u123456/file1.txt
../file1.txt
~/file1.txt
(if the current user is u123456
)more
and less
: View file content page by page.b
to go back, q
to quit.cat
: Displays the entire file content at once.head
: Shows the first few lines of a file.tail
: Shows the last few lines of a file.bat
: An enhanced cat
clone with syntax highlighting and line numbers.touch
: Creates a new empty file.>
: Overwrites the file.>>
: Appends to the file.touch my_new_file.txt && ls my_new_*
: Creates a file and lists files starting with my_new_
.whoami > my_new_file.txt && cat my_new_file.txt
: Saves the username to a file and displays its contents.date >> my_new_file.txt && cat my_new_file.txt
: Appends the current date to the file.echo "some text here" >> my_new_file.txt
: Appends text to the file.grep pattern filename
: Returns lines containing the pattern.grep free filename | wc -l
: Counts the number of lines containing "free".-c
: Specifies the range of characters to cut.-d
: Specifies the delimiter between fields.-f
: Lists the fields or columns to extract.-s
: Suppresses lines without delimiters.cut -d : -f 5 file.txt
: Extracts the fifth field from file.txt
, using :
as the delimiter.ls -l /usr | grep ^t | cut -c 2-10
: Lists files in /usr
, filters for those starting with t
, and extracts characters 2-10 (permissions).join file1 file2
, where file1
contains "1 deKaiser" and file2
contains "1 stem", results in "1 deKaiser stem".command1 | command2 | command3
find /dev -name 't*' 2> /dev/null | grep tty | sort | head -5
/dev
starting with t
, ignores errors, filters for tty
, sorts, and shows the first 5 results.fortune
, cowsay
, and lolcat
can be combined for humorous output.fortune | cowsay | lolcat
: Displays a fortune cookie in a cow speech bubble with colors.ls -l | lolcat
adds color to the output of the long listing.htop | lolcat
adds color to the output of the htop (process monitoring) command.