Posts

Showing posts from August, 2024

Linux Directory Structure

  Directory Description /bin binary or executable programs /etc system configuration files /home home directory . It is the default current directory /opt Option or Third party softwares /tmp temporary space, typically cleared on reboot /usr User related programs /var Log files    

Logical Operators

  Logical Operator Description && Logical AND : True if both conditions on either side of the operator are true. ! Logical NOT : Negates the condition, making it true if the condition is false and vice versa. -a Logical AND : True if both conditions are true. This is deprecated; use && instead. -o Logical OR : True if at least one of the conditions is true. This is deprecated; use `     Logical AND ( && ) : if [[ -f "$file" && -r "$file" ]]; then     echo "The file exists and is readable." fi Logical OR ( || ) : if [[ -z "$var" || "$var" == "default" ]]; then     echo "The variable is either empty or set to 'default'." fi Lo...

If Condition FlAGS

Condition Flag Description -e True if the file exists. -f True if the file exists and is a regular file. -d True if the file exists and is a directory. -r True if the file exists and is readable. -w True if the file exists and is writable. -x True if the file exists and is executable. -s True if the file exists and is not empty (has a size greater than 0). -L True if the file exists and is a symbolic link. -z True if the string is empty. -n True if the string is not empty. -eq True if two numbers are equal. ...

$$$$ Symbols in shell scripting

  Special Variable Description $# Number of positional parameters (arguments) passed to the script. $? Exit status of the last executed command. A value of 0 usually indicates success, and any non-zero value indicates an error. $0 The name of the script or command that is being executed. $1 , $2 , ... The first, second, and subsequent positional parameters passed to the script. $1 is the first argument, $2 is the second, and so on. $* All the positional parameters passed to the script, treated as a single word. "$@" All the positional parameters passed to the script, treated as separate words. This preserves each parameter as a distinct word, even if they contain spaces. ...

CURL Commands

Flag Description -A, --user-agent <string> Specifies the User-Agent string to send to the server. -b, --cookie <data> Sends cookies to the server. Can be a string or a file name. -c, --cookie-jar <file> Writes cookies to the specified file after the transfer. -d, --data <data> Sends data in a POST request. Can be used with application/x-www-form-urlencoded or application/json (with -H ). -F, --form <name=content> Submits form data. Useful for file uploads and multipart forms. -G, --get Forces curl to use the GET method instead of POST when -d is used. -H, --header <header> Adds a custom header to the request. Multiple h...