systems. It allows users to interact with the operating system by typing commands,
which the system then executes. The command line provides a powerful and flexible
way to perform various tasks, such as managing files and directories, running
programs, and performing system maintenance.
Here are some commonly used Unix command line commands and their usage:
1. "ls" - Lists the files and directories in the current directory.
○ Options:
■ "-l" displays the files and directories in a long format, including
file permissions, size, and modification date.
■ "-a" shows hidden files and directories that begin with a "."
■ "-t" sorts the files and directories by modification date (newest
first)
■ "-r" sorts the files and directories in reverse order
2. Example: "ls -l" will display the files and directories in the current directory in a
long format.
3. "cd" - Changes the current working directory.
○ Usage: "cd [directory]" where directory is the name of the directory you
want to change to.
○ "cd .." will change to the parent directory
○ "cd ~" will change to the home directory.
4. Example: "cd Documents" will change the current working directory to the
"Documents" directory.
5. "mkdir" - Creates a new directory.
○ Usage: "mkdir [directory]" where directory is the name of the new
directory you want to create.
○ "-p" option creates any missing parent directories.
6. Example: "mkdir myfolder" will create a new directory called "myfolder" in the
current working directory.
7. "rm" - Removes files and directories.
○ Usage: "rm [file]" where file is the name of the file you want to delete.
○ "-r" option is used to remove directories and their contents recursively.
○ "-f" option forces removal without prompting for confirmation.
8. Example: "rm myfile.txt" will remove the file "myfile.txt" from the current
working directory.
9. "cp" - Copies files and directories.
○ Usage: "cp [source] [destination]" where source is the file or directory
you want to copy and destination is the location where you want to
copy it to.
○ "-r" option is used to copy directories and their contents recursively.
○ "-f" option overwrites the destination file if it already exists.