Operating Systems & Administration
[Day 1] 7. Some Basic Commands
D
DITISS AdminShell Information
- : Displays the default shell of your system.
echo $SHELL
Directory and File Listing
-
: Displays the contents of the current directory.
ls -
: Displays the contents of a specified path.
ls <path> -
: Displays the contents of the root directory.
ls / -
: Displays the contents of the boot directory.
ls /boot -
: Displays the contents of the home directory.
ls /home/ -
: Displays all device files.
ls /dev -
: Displays the entire directory hierarchy recursively, showing all files and sub-directories.
ls -R -
: lists all files including hidden ones (starting with
ls -a). -
: does the same but excludes
ls -A(current directory) and.(parent directory)... -
:
ls -l -
: Changes current working directory to
cddirectory.home -
: Same as previous. Changes current directory to
cd~directory.home -
: Changes the current directory to
cd Desktop/.Desktop -
: Changes the present working directory to
cd dir1.dir1 -
: Changes the present working directory to its
cd ..orparentdirectory.previous -
: Changes to previous present working directory.
cd - -
Note: In every directory, by default two entries are made that are hidden. The first one is
and.,..indicates current directory and.indicates parent directory...
System Information
- : Displays CPU information stored in the
cat /proc/cpuinfodirectory./proc - : Displays memory information stored in the
cat /proc/meminfodirectory./proc - : Displays the current date and time.
date - : Sets the date and time.
date -s - : Displays the manual page for a command (e.g.,
man <command>for the date command).man date
Calendar
- : Displays the calendar of the current month.
cal - : Displays the calendar for the current year.
cal -y - : Displays the calendar for a specific year.
cal -y <year> - : An alternative command for displaying calendars.
ncal
File and Directory Operations
Working Directory
- : Displays the present working directory.
pwd
Creating Directories
- : Creates a directory with the specified name.
mkdir <directory>- Example:
mkdir ditiss
- Example:
- : Creates multiple directories.
mkdir <dir1> <dir2> <dir3>- Example:
mkdir dir1 dir2 dir3
- Example:
- : Creates nested directories in one command.
mkdir -p d1/d2/d3- Example:
mkdir -p d1/d2/d3
- Example:
Clearing Terminal
- : Clears the terminal.
clr - Shortcut:
Ctrl + L
Removing Directories
- : Removes an empty directory.
rmdir <directory>- Example:
rmdir dir1
- Example:
- : Removes a directory and its contents recursively.
rm -r <directory>- Example:
rm -r dir2
- Example:
File Operations
- : Creates an empty file.
touch <file>- Example:
touch file.txt
- Example:
- : Displays the contents of the specified file.
cat <file>- Example:
cat file.txt
- Example:
- : Creates or overwrites a file with content.
cat > <file>- End the input with .
Ctrl + D
- End the input with
- : Appends content to an existing file.
cat >> <file> - : Removes the specified file.
rm <file>- Example:
rm file.txt
- Example:
Copying and Moving Files
- : Copies files or directories.
cp <source> <destination>- Example: (Copies
cp file.txt dir1tofile.txt)dir1 - : Recursively copies directories.
cp -r <source> <destination> - Example: (Copies
cp -r dir1 dir2todir1)dir2
- Example:
- : Moves or renames files or directories.
mv <source> <destination>- Example: (Renames
mv file.txt moved.txttofile.txt)moved.txt - Example: (Moves
mv file.txt dir2tofile.txt) In this example,dir2should already be created otherwise this command won't work.dir2
- Example:
Shortcut Keys
- : Clears the terminal.
Ctrl + L - : Ends input in file creation (
Ctrl + Dorcat >).cat >>
Notes
- is only used for removing empty directories.
rmdir - removes non-empty directories and their contents.
rm -r - When we use touch command on an existing file, then it updates its time stamp.
- While creating a file, if you include a dot (.) before the file name then the file will be hidden. Same for directories as well.
Read Next
8/26/2026
[Day 2] 1. More about File Systems
### Disk Partition Conventions #### **In Windows** - **Hard Disk**: Disk0, Disk1, ... - **Partitions**: C:, D:, E:, ... #### **In Linux**...
8/26/2026
[Day 2] 2. Some more commands
### File Information Using `stat` To retrieve specific information about a file, you can use the `stat` command in Linux. Here are some examples:...