which
which <command>
Describes the location of an application in the computer’s file system. If an application is not installed on the computer
and its parent directory is not part of the system’s $PATH, which will report an error.
Example:
$ which clear
/usr/bin/clear
cat – Concatenate and Display Files
cat <path/to/filename>
Displays the contents of <path/to/filename> to standard out. <path/to/filename>
Example:
$ cat /root/text.txt
Unchain Code is awesome!
cd – Change Directory
Change to another current directory.
Example:
$ cd /home/username/Documents
cd .. : Moves up one directory level.
cd ~ : Moves to the home directory.
cd / : Moves to the root directory.
pwd – Print Working Directory
Displays the full path of the current working directory.
Example:
$ pwd
/home/username
ls – List Directory Contents
Lists files and directories in the current directory.
Example:
$ ls
Documents Downloads Music Pictures Videos
touch – Create an Empty File
Creates an empty file or updates the timestamp of an existing file.
Example:
$ touch myfile.txt
mkdir – Make Directory
Creates a new directory.
Example:
$ mkdir new_directory
Creates parent directories as needed.
Example:
$ mkdir -p projects/2024/linux_guide
rm – Remove Files or Directories
Deletes files or directories.
Example:
$ rm myfile.txt
rm -r directory_name : Recursively removes a directory and its contents.
rm -i : Asks for confirmation before each file deletion.
rm -rf directory_name : Forcefully removes a directory and its contents without asking for confirmation.
cp – Copy Files or Directories
Copies files or directories from one location to another.
Example:
$ cp file1.txt /home/username/Documents/
Recursively copies a directory and its contents.
$ cp -r /home/username/Documents /home/username/Backup/
mv – Move or Rename Files or Directories
Moves or renames files or directories.
Example:
$ mv file1.txt file2.txt : This renames file1.txt to file2.txt.
$ mv file1.txt /home/username/Documents/
chmod – Change File Permissions
Changes the permissions of a file or directory.
Example:
$ chmod 755 script.sh
7 (rwx): Full permissions (read, write, execute).
5 (r-x): Read and execute permissions.
0 (---): No permissions.
nano – Text Editor
Opens the nano text editor to create or edit files.
Example:
$ nano myfile.txt
grep – Search Text in Files
Searches for a specific pattern or text in files.
Example:
$ grep "search_term" file.txt
$ grep -r "search_term" /path/to/directory/
man – Manual Pages
Displays the manual page for a command, which contains detailed information about how to use it.
Example:
$ man ls