CheatSheet
Display detailed information about the specified directory or file
1
ls -ld ebook-convert
ls
: The command used to list directory contents.-l
: This option stands for “long format,” which provides detailed information, including permissions, owner, group, size, and modification date.-d
: This option tellsls
to display information about the directory itself rather than its contents. Without this option,ls -l
would list the contents of the directory instead of the directory itself.Permissions: Indicates who can read, write, or execute the file or directory.
Owner: The user who owns the file or directory.
Group: The group associated with the file or directory.
Size: The size of the file or directory in bytes.
Modification Date: The date and time when the file or directory was last modified.
Name: The name of the directory or file.
Output
1
lrwxrwxrwx 1 root root 26 Jul 1 13:23 ebook-convert -> /app/calibre/ebook-convert
Navigate to the parent directory of the current working directory
1
cd ..
Delete files or directories
The
rm
command permanently deletes the file without sending it to a trash/recycle bin. Use with caution!1
2
3
4
5
6
7
8
9
10
11
12# Delete single file
rm example.txt
# Delete with prompted for confirmation to delete
rm -i example.txt
# Delete a directory
rm -r directory_name
# Forcing delete files and directories without prompting for confirmation, even if the files are write-protected.
# USE WITH CAUTION!!!
rm -rf /path/to/directory-r
: Stands for “recursive.” This option allows you to delete directories and their contents, including all subdirectories and files within them.-f
: Stands for “force.” This option forces the removal of files and directories without prompting for confirmation, even if the files are write-protected.-i
: Prompted for confirmation before deletion.Display the contents of the file
1
cat example.txt
Opens the file in the Vi text editor
1
vi example.txt
i
: Insert mode and start editing the text.Esc
: Return to command mode for navigation and command entry.:wq
: Save and exit after editing.:wq!
: Force saving and exit after editing even if there are warnings or the file is read-only.:q!
: Exit without saving.!
: Ensure the commands are executed forcefully.
Reference
About this Post
This post is written by Andy, licensed under CC BY-NC 4.0.