Mastering Linux Commands
The Basics of Linux Commands
You can use a shell program to interact with the Linux kernel. Commands are text-based, and can be executed from the terminal or in an ASCII script.
A command has three components; a command, options and arguments. The command is the name of a utility or program, and the options are the switches you can string together.
ls is a command that lists the contents of files and directories in Linux. It can be used with various flags to perform a variety of different tasks. For example, it can be used to display file permissions and other information in a human-readable format. It can also be used to sort files by file size or modification time.
Mastering the ls command can feel like unlocking a new level in a video game. It can transform a simple file list into a detailed directory listing, showing details like file permissions and number of links.
grep is a powerful line-oriented text search program. It provides a number of options for customization. For example, it allows you to select only non-empty parts of matching lines. It also supports recursion and can search multiple files.
Unlike other shell commands, grep does not require the pattern to contain whitespace characters. It also does not have a limit on input length or a default collating order. Moreover, it can match arbitrary characters.
One of the most useful commands is mv, which moves or copies files. It can also change a file’s permissions. The command cd changes directories. Each directory has a parent and can contain multiple files.
Unix commands usually have three parts; command name, options and arguments. The command name is a program or utility, and the options are commands that modify the command’s behavior and arguments are input to it.
The mkdir command is an effective way to create folders in Linux and other Unix-based operating systems. It also lets users modify permissions for directories at a specified path.
It ignores a Directory parameter that names an existing directory, unless the -p option is given. The mkdir command will then report an error if that directory already exists.
The mkdir command will create the directories with read, write and execute permissions for the user (rwxr-xr-x). If the umask is not set or the parent directory has the setgid bit set, it will inherit those settings.
The cd command changes your current directory. It can be used with or without an argument. With no argument, it will take you back to your home directory. Alternatively, you can type cd
All commands have three parts; a command name, options and arguments. The command name is the name of the program that you are executing. The options are the features of the program, and the arguments are the data that you provide to the program.
cp copies one file to another. Its two mandatory options are source and destination. The new file will retain the same contents as the original. This allows you to rename a file or move it to a different location without changing the contents of the old file.
Unix commands often have three parts; command, options and arguments. Usually, the options are separated by a hyphen.
Used to redirect output from STDIN to a file. It is useful when a command produces too much output. More displays a screenful of text at a time, while less provides more emulation and features.
The rm command is one of the first commands most new Linux users encounter. It is a powerful tool that deletes files, groups of files, and entire directories. It also has an interactive mode that prevents accidental deletions.
In Unix-based systems, rm performs the unlink() system call on each file in its path argument. This removes all the links to a given file, and frees up space on the filesystem.
The pwd command prints the pathname of your current working directory on the screen. The command also stores the path in the $PWD environment variable, which can be useful for passing the cwd value to a script.
The pwd command has several flags for specific behavior. For example, the -L flag resolves all symbolic links when printing the path to your current directory. You can also personalize the pwd command by storing its value in a variable and adding a message using echo.
awk (or gawk) is a powerful command-line utility for processing text data that is arranged in columns. It can be used to read data directly from standard input – STDIN, or it can be piped to and from other programs.
awk can search its input for a pattern, and then print or otherwise process the matched lines. It also has several functions that can manipulate and filter text. For example, join can combine multiple strings into a single string, and mktime turns a date into a formatted timestamp.