1. Navigating the File System
Command | Platform | Use |
---|---|---|
mkdir |
Windows, Linux, macOS | The shell command mkdir is used to make a new directory in the filesystem according to its argument. In simple terms, it creates a new directory. Example: mkdir new_folder creates a directory named "new_folder" in the current location. |
cd |
Windows, Linux | Change the current directory. Example: cd Documents . |
dir |
Windows | List the contents of a directory. |
ls |
Linux, macOS | List the contents of a directory. |
pwd |
Linux, macOS | Print the current directory path. |
cd .. |
Windows, Linux | Move up one directory level (to the parent directory). |
cd \ |
Windows | Move to the root directory. |
cd / |
Linux, macOS | Move to the root directory. |
touch |
Linux, macOS | The shell command touch is used to create a new, empty file in the filesystem.Example: touch example.txt , creates a file named "example.txt" in the current location if it doesn't already exist. If "example.txt" exists, it updates its timestamp. |
2. Viewing and Changing the File System
Command | Platform | Use |
---|---|---|
type |
Windows | Display the contents of a file. Example: type file.txt . |
cat |
Linux, macOS | Concatenate and display file contents. Example: cat file.txt . |
echo |
Windows, Linux | Output text to the terminal. Example: echo Hello . |
ren or rename |
Windows | Rename a file or directory. Example: rename old.txt new.txt . |
mv |
Linux, macOS | Move or rename a file/directory. Example: mv old.txt new.txt . |
copy |
Windows | Copy a file. Example: copy file.txt backup.txt . |
cp |
Linux, macOS | Copy a file. Example: cp file.txt backup.txt . |
del |
Windows | Delete a file. Example: del file.txt . |
rm |
Linux, macOS | Delete a file. Example: rm file.txt . |
mkdir |
Windows, Linux | Create a new directory. Example: mkdir new_folder . |
rmdir |
Windows, Linux | Remove an empty directory. Example: rmdir old_folder . |
3. Redirecting Input and Output
Command | Platform | Use |
---|---|---|
> |
Windows, Linux | Redirect output to a file, overwriting it. Example: echo Hello > file.txt . |
>> |
Windows, Linux | Redirect output to a file, appending to it. Example: echo World >> file.txt . |
| (pipe) |
Windows, Linux | Send output of one command as input to another. Example: dir | find "file" . |
tee |
Linux, macOS | Write output to both a file and the terminal. Example: ls | tee output.txt . |