
Come along with me on a public learning journey into AWS Cloud and DevOps, designed specifically for those without a technical background. I'll be documenting each step in straightforward, easy-to-understand language to help others make a smooth transition into DevOps. Together, we'll delve into continuous integration, deployment, and automation, breaking down complex concepts into manageable, actionable insights.
In Linux, navigation and directory commands are essential for interacting with the file system. Here are some commonly used commands:
Navigation Commands:
cd (Change Directory):
Usage:
cd [directory]Example:
cd DocumentsMoves you to the specified directory. Use
cdwithout arguments to return to your home directory (cdorcd ~).
pwd (Print Working Directory):
Usage:
pwdExample: Shows the current directory path you are in.
ls (List):
Usage:
ls [options] [directory]Example:
ls -lLists files and directories in the current directory. Common options include
-l(long format, showing details like permissions and sizes),-a(show hidden files), and-h(human-readable sizes).
Directory Commands:
mkdir (Make Directory):
Usage:
mkdir [directory name]Example:
mkdir DocumentsCreates a new directory with the specified name.
rmdir (Remove Directory):
Usage:
rmdir [directory name]Example:
rmdir DocumentsRemoves the specified empty directory.
cp (Copy):
Usage:
cp [options] source destinationExample:
cp file1.txt /path/to/destinationCopies files and directories. Use
-roption to copy directories recursively.
mv (Move):
Usage:
mv [options] source destinationExample:
mv file1.txt /path/to/destinationMoves files and directories. Can also be used to rename files/directories within the same parent directory.
rm (Remove):
Usage:
rm [options] file/directoryExample:
rm file.txtDeletes files and directories. Use with caution, as deleted files are not typically recoverable from the command line.
chmod (Change Mode):
Usage:
chmod [options] mode file/directoryExample:
chmod +xscript.shChanges the permissions (read, write, execute) of files and directories.
chown (Change Owner):
Usage:
chown [options] owner:group file/directoryExample:
chown user1:group1 file.txtChanges the owner and group of files and directories.
Some tips!
1. ls -la command
ls -la is a command in Linux used to list all files and directories in a detailed format, including hidden ones.
Here’s what each part of the command does:
ls: This is the command to list directory contents.-l: This option (lowercase "L") specifies that the output should be in long format. Long format typically includes information such as permissions, number of links, owner, group, size, and timestamp.-a: This option stands for "all" and includes all files and directories, including hidden ones (those whose name starts with a dot.).
So, ls -la together lists all files and directories in the current directory (.) in a detailed (long) format, showing all files, including hidden ones. It's a common command used to get a comprehensive view of everything within a directory, including files and directories that might not be visible with a simple ls command.
ls-r | cp-r |chmod -R | where -r stands for recursive
ls -r:- This option is used to reverse the order of the sort to get a reverse listing of files. By default,
lslists files and directories in alphabetical order. Using-rreverses this order lists them in reverse alphabetical order.
- This option is used to reverse the order of the sort to get a reverse listing of files. By default,
Example:
ls -r
cp -r:- In the
cpcommand,-rstands for. It is used to copy directories and their contents recursively, including all subdirectories and files within them.
- In the
Example:
cp -r directory1 directory2
chmod -R:- In the
chmodcommand,-R(uppercase "R") stands for recursive as well. It is used to change file permissions recursively for all files and directories within a directory.
- In the
Example:
chmod -R 755 directory
If you encounter -r in a command, it's crucial to check the specific command context to understand its exact function, as it can vary significantly between commands.
-v typically stands for "verbose "
In Linux commands, -v typically stands for "verbose". Its exact function can vary depending on the command being used. Here are a few common commands where -v is used:
cp -v:- In the
cp(copy) command,-vstands for verbose mode. When you usecp -v, it displays detailed information about each file being copied, including the source file and destination file paths.
- In the
Example:
cp -v file1.txt /path/to/destination/
mv -v:- Similarly, in the
mv(move) command,-valso enables verbose mode. It displays information about each file or directory being moved, including the source and destination paths.
- Similarly, in the
Example:
mv -v file1.txt /path/to/destination/
rm -v:- In the
rm(remove) command,-vagain enables verbose mode. It displays the names of files and directories as they are being removed.
- In the
Example:
rm -v file1.txt
chmod -v:- In the
chmod(change mode) command,-vcan be used to display a message for each file processed, indicating the changes made to file permissions.
- In the
Example:
chmod -v +x script.sh
The -v option is useful when you want to see more detailed information about the operation being performed by a command. It provides feedback and confirmation of each action taken by the command, making it easier to track and verify what changes or operations are being executed.
-f typically stands for "force"
In Linux commands, the -f an option often stands for "force". Its exact behavior can vary depending on the specific command being used. Here are a few common commands that -f is used:
rm -f:- In the
rm(remove) command,-fstands for force. It suppresses prompts to confirm the removal of files. It's commonly used in scripts or when you want to delete files without being prompted for confirmation.
- In the
Example:
rm -f file1.txt
cp -f:- In the
cp(copy) command,-fstands for force as well. It causes thecpcommand to overwrite existing destination files without prompting for confirmation.
- In the
Example:
cp -f file1.txt /path/to/destination/
mv -f:- Similarly, in the
mv(move) command,-fforces the move operation without prompting for confirmation, even if it would overwrite existing files.
- Similarly, in the
Example:
mv -f file1.txt /path/to/destination/
chmod -f:- In the
chmod(change mode) command,-fdoesn't force anything related to permissions directly. Instead, it might suppress error messages that would normally be displayed if the command encounters problems.
- In the
Example:
chmod -f +x script.sh
The -f option is useful when you want to carry out an operation forcefully, without being prompted for confirmation or when you want to suppress certain types of errors or warnings. However, use it with caution, especially with commands like rm -f, as it can delete files irreversibly without a chance to recover them.
File maintenance commands in Linux are essential for managing files and directories effectively. Here's an explanation of each command you mentioned:
touch:
Usage:
touch [options] fileDescription: The
touchcommand is used to create empty files or update the access and modification timestamps of existing files. If the file doesn't exist,touchcreates an empty file with the specified name. If it does exist,touchupdates the timestamps to the current time.
Example:
touch file.txt
find:
Usage:
find [path...] [expression]Description: The
findcommand is used to search for files in a directory hierarchy based on various criteria such as file name, permissions, type, size, and more. It is powerful and versatile, allowing complex searches and actions on the found files.
Example:
find . -name "*.txt"
umask:
Usage:
umask [mode]Description: The
umaskcommand sets the default permissions for new files and directories created by the current shell session. It works by subtracting the specified mode from the default permission settings.
Example:
umask 022
chmod:
Usage:
chmod [options] mode file/directoryDescription: The
chmodcommand is used to change the permissions (read, write, execute) of files and directories. Permissions can be specified using symbolic or octal notation.
Example:
chmod +x script.sh
chown:
Usage:
chown [options] owner:group file/directoryDescription: The
chowncommand changes the owner and/or group of a file or directory to the specified owner and/or group.
Example:
chown user1:group1 file.txt
chgrp:
Usage:
chgrp [options] group file/directoryDescription: The
chgrpcommand changes the group ownership of a file or directory to the specified group.
Example:
chgrp group1 file.txt
cp:
Usage:
cp [options] source destinationDescription: The
cpcommand copies files and directories. It can copy single or multiple files, as well as entire directories and their contents. Use the-roption for recursive copying of directories.
Example:
cp file1.txt /path/to/destination/
mv:
Usage:
mv [options] source destinationDescription: The
mvcommand moves (or renames) files and directories from one location to another. It can also be used to rename files and directories within the same parent directory.
Example:
mv file1.txt /path/to/destination/
wc:
Usage:
wc [options] fileDescription: The
wc(word count) command is used to count the number of lines, words, and bytes in a file. It's useful for obtaining basic statistics about the content of text files.
Example:
wc -l file.txt
These commands are fundamental for file and directory maintenance tasks in Linux, enabling users to manage permissions, ownership, content, and locations of files efficiently from the command line.



