How to Use grep to Find Starting and Ending Pattern in Linux
The special characters “^” and “$” in combination can be used to retrieve words or sentences starting and at the same time ending with a specified character.
The special characters “^” and “$” in combination can be used to retrieve words or sentences starting and at the same time ending with a specified character.
To match the exact string using the “grep” command, use the “grep -w “matching_string”
To count the total number of occurrences of the specified word/pattern, use the “grep” command with the “wc(word count)” and “tr(translates)” options.
The “ps -ef | grep processname” command filters out a process from a list of running processes and displays information in the Linux system.
To use the OR condition in the grep command, specify the patterns separated with “\”, or use the Flags “E” or “e” in the given syntax.
In Linux, the grep command is utilized to highlight (shows the match) the specific word, character, or string after searching the entire content in a file.
In Linux, the pgrep command allows you to find the PID of a process, which can be useful for terminating the process or sending it a signal.
The grep command is used to find the information for multiple strings in any file or directory that you are looking for in Linux.
The grep command allows users to find or sort data according to syntax matches. This article covers the detail on how to exclude in grep.
The grep command can be used to find the words in the files of Linux. The words can be found in the current directory and its sub-directories.
To execute the grep command to search through all the files in a directory, you need to navigate to the directory or enter the exact path and use the “*” sign.
To list the running services on Debian 12, users can use the pstree command, service command, and the systemctl command.
The useradd command line tool is used to add and update the information of the users in Debian Linux. This command can be run with its various options.
To fix the “curl command not found” on Debian, make sure the curl command package is installed. If not then, run the “sudo apt install curl -y” in the terminal
The existing username in Linux can be changed with the help of the built-in “usermod” command that also changes the user’s home directory.
The “ls -ltr” lists the content of the specified directory in a (-l)long list format (-r)reversely which is sorted by its last modification date and time(-t).
In Linux, the “sed” command removes the whitespaces from text files with the combination of its subcommands, supported options, and regular expressions.
To list the groups on Debian 12, different command line utilities can be used. These include the getent, groups, libuser-lid,and id commands.
The & ampersand operator and && AND operator in Linux commands are used to run processes in the background or in a conditional way.
To find all the files containing the specific text or string on Linux, use the grep command with its “rnwe” options. Also, the ack and rg commands can be used.
To delete the exported environment variable in the Linux shell, use the unset command. To use it, open the terminal and run “unset [variable name]”.
To check the CPU temperatures, install and use the software packages of “psensor”, “lm-sensors”, “hardinfo”, “glances”, and “smartmontools” in Linux distros.
To disable the IPv6 on Debian 12, either open the sysctl configuration file or blacklist the IPv6 kernel module. Both methods are explained in this blog.
To search for Debian’s packages, use any of the commands from apt, apt-file, apt-cache, aptitude, dpkg, dlocate, and snap.
To install the i3 Window Manager on Ubuntu, open the terminal and run the command “sudo apt install i3 -y”. Its installation has been explained in this blog.
To add the user to the group, run the command “sudo usermod -a -G [Group Name] [User]” in Debian 12. It can be deleted from the group using the deluser command.
The VirtualBox Guest Additions can be installed on Debian 12 by inserting the CD image of Guest Additions, mounting it, and running the “VBoxLinuxAdditions.run”
To add and remove the users on Debian 12, either use the terminal or the GUI method. In the terminal use the “adduser” and “deluser” to add the users.
An exit code of “2” means the program or command could not execute successfully. It usually occurs when the command syntax needs to be corrected.
To install CUDA on Ubuntu, execute the “sudo apt install nvidia-cuda-toolkit” command. Before it, check the status of the GPU that supports the CUDA or not.
Linux offers the “Smartctl”, and “nvme-cli” command line tools and “Disks” application in GUI to test the health of SSD/HDD.
JSON scripting is not supported in shell scripting, but with the help of the jq command, it is made possible to the best extent. The curl command also helps.
In Bash, the “<<<” operator means “here strings.” It allows users to pass a string as the standard input to a command via the “command <<< string” syntax.
To find all SSH login attempts, use the “grep,” “journalctl,” or the combination of “cat” and “egrep” commands with the “/var/log/auth.log” file.
To uninstall a .deb installed package with dpkg, use the “sudo apt -remove
The sshd Logs are stored in the “/var/log/auth.log” file. These log details can be displayed using the “grep”, “lastlog”, and the “journalctl” commands.
The “lrwxrwxrwx” permission specifies that the symbolic link to another file has read, write, and execution permissions to all its users and groups.
In Linux, use the WPA_Supplicant to connect with the Wi-Fi networks. Also, establish connections with hidden, insecure networks and WEP routers.
To view all UUIDs for all available disks on the Linux operating system, use the “blkid”, “lsblk”, “ls”, “hwinfo”, “udevadm”, “tune2fs”, “dumpe2fs” commands.
In Linux, the user can use the “nmap”, “netstat”, “netcat”, “/dev/tcp” or “lsof” tools as an alternative besides the “telnet” tool.
In Ubuntu, the “wheel” group is a special user group that provides administrative access to certain users on a system to perform administrative tasks.
To check the RAM size in the Linux, utilize the “/proc/meminfo file”, “free”, “top”, “vmstat”, “dmidecode”, “lshw”, or “hwinfo” utilities
In Ubuntu, the “ls”, “locate”, and “grep” command-line utilities can be utilized to get the absolute path of the “php.ini” configuration file.
To find and kill the zombie process on Linux, list down the zombie process, and send the SIGCHLD signal to its parent process.
In Ubuntu, the Apache access log files are stored in the “/var/log/apache2” directory. These files contain details of all the requests made to the web server.
Linux and its distributions offer the pre-installed “id”, “echo”, “lslogin”, and “getent” command line utilities for finding user ID from the terminal.
To run the SSH server on a port other than 22 is possible by changing the port number in the “sshd_config” configuration file
While uninstalling docker, a few configuration files and components must be manually deleted through a series of commands which require execution one by one.
Multiple freezing states of Ubuntu are faced, such as freeze at boot time, the specific program, or the mouse stopping working. See the guide for solutions.
Linux and its distributions offer the “getent”, “groupmems”, “members”, and “libuser_lid” command line utilities for listing the group members of a group.
To get a list of all installed PPA repositories, utilize the “apt policy” command, “Software & Updates” utility, and “/etc/apt/sources.list” file.
To remove PostgreSQL from the system, remove all the packages of PostgreSQL by listing them. After that remove the directories and PostgreSQL users as well.
The TTY is a character-based device used as a medium for entering data, still a crucial part of the operating systems but in software form.
Ubuntu offers the “apt-cache search”, “apt search”, “apt list”, and “dpkg” commands to search available packages from the command line.
The “ldd” command stands for “List Down Dependencies”, which is used to display executable files or program-shared library dependencies.
The “/dev/null” is a powerful tool in Linux that allows users to discard unwanted data, suppress error messages, make files disappear, and many more.
In Linux, the VMware workstation is removed by the “vmware installer” Script. Furthermore, it can also be removed manually from the system.
To change the MTU size instantly in Linux, the ip, and ifconfig commands and to make them permanently make changes in the network configuration file.
Learn where and how passwords are securely stored on Linux systems and secure your system most effectively and possibly.
CentOS offers the “YUM” to install a specific version of an RPM package on a system. For this, specify the “package name” and the “version”.
CentOS / RHEL offers the “sysctl” configuration file and “kernel” module to disable IPv6 in the system. For this, setting the disable_ipv6 parameter to 1.
To show the PATH of an environment variable, execute the “echo”, “cat”, “env”, “set”, and “printenv” commands with the “PATH” variable.
The “utmp”, “wtmp”, and “btmp” files store the info of currently logged-in users, historical logs of all logins and logouts, and the failed login attempts.
In Linux, the cron logs are stored in the “/var/log/syslog” main system file that can be easily accessed through the “cat” and “grep” commands.
Linux offers the “nice” commands to run a program with a modified scheduling priority and “renice” for an already-running process.
The crontab offers the “MAILTO” parameter to set the mail address to send notifications. Once the job is executed, an email will be sent to the address.
The nmap provides advanced features to scan for vulnerabilities in a specific port, multiple ports, and the range of a port, as shown in the article.
In Linux, to list down the USB devices, use the “lsusb”, “dmesg”, “usb-devices”, “lsblk”, “df”, or “fdisk” utility in the terminal.
Linux offers the pre-installed “df”, “lsblk”, “fsck”, “file”, “mount”, and “blkid” commands to determine the file system type of mounted devices/partitions.
To list the only files in the directory, use the combination of the “ls” and “grep” utility, “find” utility, or “run-parts” utility with the “list” flag.