date |
Displays the current date and time |
cal |
Displays a calendar of the current month |
cal -y |
Displays a calendar for the entire current year |
cal -y 2020 |
Displays a calendar for the specified year (2020) |
man cal |
Displays the manual/help page for the cal command |
pwd |
Prints the current Working Directory (shows your current location in the filesystem) |
ls |
Lists files and directories in the current directory |
mkdir dir |
Creates a new directory named "dir" |
mkdir dir1 dir2 dir3 |
Creates multiple directories in a single command |
mkdir -p d1/d2/d3 |
Creates nested directories, including parent directories if they don't exist |
rmdir dir |
Removes/deletes an empty directory named "dir" |
ls d1 |
Lists contents of the directory "d1" |
ls d1/d2 |
Lists contents of the directory "d2" which is inside "d1" |
ls d1/d2/d3 |
Lists contents of the directory "d3" inside the nested path |
ls -R d1 |
Lists contents of "d1" recursively (including all subdirectories) |
cd dir1 |
Changes the current directory to "dir1" |
cd /home/sunbeam |
Changes to the specified absolute path directory |
cd - |
Changes to the previous working directory |
cd .. |
Moves up one directory level (to the parent directory) |
cd ~ |
Changes directory to the user's home directory |
cd . |
Changes to the current directory (no change, essentially) |
touch file.txt |
Creates a new empty file or updates timestamp of existing file |
touch file1.txt file2.txt file3.txt |
Creates multiple empty files in a single command |
cat > kdac.txt |
Creates a new file and allows you to input text (overwrites if file exists) |
cat kdac.txt |
Displays the contents of the file "kdac.txt" |
cat >> kdac.txt |
Appends text to an existing file (allows you to add more content) |
rm file.txt |
Removes/deletes the specified file |
cp kdac.txt karad.txt |
Copies a file from source to destination |
cp kdac.txt dir1 |
Copies the file to the directory "dir1" |
cp kdac.txt dir1/new.txt |
Copies file to dir1 with a new name "new.txt" |
cp dir1 copy |
Attempts to copy a directory (fails without -r option) |
cp -r dir1 copy |
Recursively copies a directory and its contents |
rmdir copy |
Attempts to remove directory (fails if not empty) |
rm -r copy |
Recursively removes directory and all its contents |
mv kdac.txt dac.txt |
Renames a file (or moves it to a new location with same name) |
mv file1.txt dir1 |
Moves a file to the specified directory |
mv dir1 move |
Renames a directory |
cat > numbers.txt |
Creates a new file to input numbers |
cat -n numbers.txt |
Displays file contents with line numbers |
head numbers.txt |
Shows the first 10 lines of the file |
tail numbers.txt |
Shows the last 10 lines of the file |
head -6 numbers.txt |
Shows the first 6 lines of the file |
tail -7 numbers.txt |
Shows the last 7 lines of the file |
rev dac.txt |
Reverses each line of the file character by character |
tac dac.txt |
Displays the file contents in reverse order (last line first) |
uniq numbers.txt |
Displays unique lines, removing adjacent duplicate lines |
history |
Shows the command history (list of recently used commands) |