11: OCI ‐ Basic Command Overview in Linux - pavankumarchittajallu/OCI_DOC GitHub Wiki
Basic Command Overview in Linux
1. Print Working Directory
- Command:
pwd
- Shows the full path of your current directory, helping you know where you are in the filesystem.
2. List Directory Contents
- Command:
ls
- Lists files and folders in the current directory.
- Common options:
ls -l
(detailed list)ls -a
(show hidden files).
3. Change Directory
- Command:
cd [directory]
- Moves you into the specified directory.
- Common usages:
cd ..
(move up one level)cd /path/to/dir
(move to a specific directory)cd ~
(go to home directory).
4. Make Directory
- Command:
mkdir [directory-name]
- Creates a new directory.
5. Create an Empty File
- Command:
touch [file-name]
- Creates a new empty file or updates the timestamp of an existing file.
6. Display File Contents
- Command:
cat [file-name]
- Prints the contents of a file to the terminal.
7. Copy Files and Directories
- Command:
cp [source] [destination]
- Copies files or directories.
- Use
cp -r
to copy directories recursively.
8. Move or Rename Files and Directories
- Command:
mv [source] [destination]
- Moves files/directories or renames them.
9. Remove Files and Directories
- Command:
rm [file-name]
- Deletes files.
- Use
rm -r [directory]
to remove directories and their contents. - Use
rm -d [directory]
to remove empty directories.
10. Edit Text Files
- Command:
nano [file-name]
- Opens the file in the nano text editor for editing.
11. Run Commands as Superuser
- Command:
sudo [command]
- Executes a command with administrative privileges.
12. View Manual for a Command
- Command:
man [command]
- Displays the manual page for a command.
13. Show Current User
- Command:
whoami
- Prints the username of the current user.
14. Exit Terminal
- Command:
exit
- Closes the current terminal session.