Day - 1 of internship at Aartronix

Here is your blog post, reformatted for better readability. I have consolidated duplicate entries, fixed the numbering, and applied Markdown styling to the code and lists while keeping your original wording and personal notes intact.


Asked to learn and understand linux commands (well no idea which or of what category)

Well let's go to Geeks, and start understanding linux commands.

1) access

hmm, quite useful command, i can put this in bash scripts before working on a file.

Syntax:

C
int access (const char *pathname, int mode);

Where:

  • pathname: This argument specifies the path to the file or directory you want to check.

  • mode: This argument specifies the type of access to check for. It can include one or more of the following flags:

    • F_OK flag: Used to check for the existence of a file.

    • R_OK flag: Used to check for read permission bit.

    • W_OK flag: Used to check for write permission bit.

    • X_OK flag: Used to check for execute permission bit.

Note: I ran into problems by checking for multiple modes when using bitwise & and it because of how it works, so i would use && logical operator and it works fine. Why I used bitwise &, it was used in GKG's example.

Return Value:

  • The access function returns 0 if the file has the requested access permissions.

  • It returns -1 if the file does not have the requested permissions or if the file does not exist. In such cases, the global variable errno is set to indicate the error.


2) accton

Starts accounting for processes and command.

It toggles accounting of processes and commands. accton is one of important Linux/Unix command which is used by the administrator to monitor user activities. It is used to turn on or turn off the process for accounting or change the info process accounting file. When the command is run in the terminal without any argument, it stops the process accounting.

Syntax:

Bash
accton [OPTION] on|off| file_name

By default its path is /var/log/account/pacct

Where:

  • on: Turns on process accounting using the default or specified file.

  • off: Turns off process accounting.

  • file_name: Specifies the file where process accounting data should be saved.


3) aclocal

Scans the system for installed tools and sets up the environment.

It seems this command is used for development.

For sake of documenting and knowing:

aclocal command in Linux is used to automatically generate aclocal.m4 files from configure.in file. automake in Linux contain a lot of autoconf macros that can be used in the different packages. These macros must be defined in the aclocal.m4. If not, then it can’t be accessed by the autoconf.

The aclocal command first scans for macro definitions in the .m4 files in its default directory (/usr/share/aclocal on some systems) and also in the file acinclude.m4 after which it scans for macros used in the configure.in file. It will generate an aclocal.m4 file that contains definitions of all the m4 macros required by autoconf.

Syntax:

Bash
aclocal [, OPTION/]... [, SRCDIR/]

Where:

  • [OPTION]: Specifies various options to control the behavior of the aclocal command.

  • [SRCDIR]: The source directory containing the configure.in or configure.ac file.


4) acpi

It is the command in Linux that helps the users in managing power settings. It also helps in monitoring the hardware status efficiently. It facilitates with providing essential information such as battery health, CPU temperatures, and fan speeds, providing support in system maintenance and performance optimization.

  • -b, --battery: battery information

  • -i, --details: show additional details if available

temperature trip points,

battery capacity information

  • -a, --ac-adapter: ac adapter information

  • -t, --thermal: thermal information

  • -c, --cooling: cooling information

  • -V, --everything: show every device, overrides above options

  • -s, --show-empty: show non-operational devices

  • -f, --fahrenheit: use fahrenheit as the temperature unit

  • -k, --kelvin: use kelvin as the temperature unit

  • -d, --directory <dir>: path to ACPI info (/sys/class resp. /proc/acpi)

  • -p, --proc: use old proc interface instead of new sys interface

  • -h, --help: display this help and exit

  • -v, --version: output version information and exit


5) acpi_available

acpi_available is a command in Linux that tests whether the ACPI (Advanced Configuration and Power Interface) subsystem is available or not.


6) acpid

It provides intelligent power management on a system and is used to notify the user-space programs about the ACPI events.


7) addr2line

Used to convert addresses into file names and line numbers.


8) agetty

It is a Linux version of getty, which is a Unix program running on a host computer that manages physical or virtual terminals to allow multi-user access.


9) alias

Instructs the shell to replace one string with another string while executing the commands.

Example:

Bash
alias ll 'ls -l'

To remove:

Bash
unalias ll

10) apt

It is package manager for Debian and its derivatives.

Most used commands:

  • list: list packages based on package names

  • search: search in package descriptions

  • show: show package details

  • install: install packages

  • reinstall: reinstall packages

  • remove: remove packages

  • autoremove: automatically remove all unused packages

  • update: update list of available packages

  • upgrade: upgrade the system by installing/upgrading packages

  • full-upgrade: upgrade the system by removing/installing/upgrading packages

  • edit-sources: edit the source information file

  • satisfy: satisfy dependency strings


11) apt-get

Maintained for stability in comparison to apt, for scripting and automation.

Most used commands:

  • update: Retrieve new lists of packages

  • upgrade: Perform an upgrade

  • install: Install new packages (pkg is libc6 not libc6.deb)

  • reinstall: Reinstall packages (pkg is libc6 not libc6.deb)

  • remove: Remove packages

  • purge: Remove packages and config files

  • autoremove: Remove automatically all unused packages

  • dist-upgrade: Distribution upgrade, see apt-get(8)

  • dselect-upgrade: Follow dselect selections

  • build-dep: Configure build-dependencies for source packages

  • satisfy: Satisfy dependency strings

  • clean: Erase downloaded archive files

  • autoclean: Erase old downloaded archive files

  • check: Verify that there are no broken dependencies

  • source: Download source archives

  • download: Download the binary package into the current directory

  • changelog: Download and display the changelog for the given package


12) aptitude

You get a graphical interface of package management.


13) banner

Print ascii art of string you provide.


14) chmod

Change permission of rwx for owner, group and others.

  • read: 4

  • write: 2

  • execute: 1

  • hidden: 0

  • rwx: 7

            EXAMPLE:
            chmod 700 sample.txt
                
            here owner will have rwx permission and group and other won't be able to see the file.


15) lsusb

It displays information on USB buses and device connected to them.

"KHABRI CHHE USB PORTS NI KHABR RAKHE"


16) while

Used to repeatedly execute a set of command as long as the COMMAND returns true.


17) yes

Used to print a continuous output stream of given STRING. If STRING is not mentioned then it prints ‘y’.


18) | (Pipe)

We can give output of left hand side to right hand side.

Example:

Bash
yes "Hello GFG" | head -n 100 > jayesh.txt

In this example, "yes" generates an infinite stream of "Hello World" strings, which is then piped to the "head" command to limit the output to 100 lines. Finally, the content is redirected to the "dummy.txt" file.


19) grep

It is used to search an expression/string in files.

Syntax of grep Command in Unix/Linux:

The basic syntax of the grep command is as follows:

Bash
grep [options] pattern [files]
  • [options]: These are command-line flags that modify the behavior of grep.

  • [pattern]: This is the regular expression you want to search for.

  • [file]: This is the name of the file(s) you want to search within. You can specify multiple files for simultaneous searching.

Comments