Found 1383 Articles for Open Source

What Does cd do on Linux

Satish Kumar
Updated on 25-Jan-2023 10:49:50

2K+ Views

cd stands for "change directory" and is used to navigate the file system on a Linux computer. When used with a specific directory path as an argument, cd will change the current working directory to that location. For example, the command cd /home/user/documents will change the current working directory to the "documents" folder located within the "user" folder in the root directory. If you use cd command without any argument it will take you to your home directory. The Meaning of – With cd The "-" (dash) symbol is a shortcut that can be used with the cd command to ... Read More

Anonymous and Named Pipes in Linux

Satish Kumar
Updated on 25-Jan-2023 10:49:10

871 Views

In Linux, a pipe is a mechanism that allows the output of one command to be used as the input for another command. Pipes allow for powerful command line operations by allowing the output of one command to be used as input for another command. Pipes Pipes are a feature in Linux and other Unix-like operating systems that allow the output of one command to be passed as input to another command. They are represented by the "|" symbol, and are often used to chain multiple commands together to perform complex tasks. For example, the command "ls -l | grep ... Read More

Sending Emails From Terminal In Linux

Satish Kumar
Updated on 25-Jan-2023 10:48:14

924 Views

You can send emails from the terminal in Linux by using the command line tool called "mail." This tool is typically pre-installed on most Linux distributions. To send an email, you would use the syntax − echo "message body" | mail -s "subject" recipient@email.com You can also include attachments by using the -a option and specifying the path to the file you want to attach. echo "message body" | mail -s "subject" -a /path/to/attachment recipient@email.com You can also use other command line mail clients such as mutt, mailx, etc. Architecture of an Email System An email system consists ... Read More

Read the Source Code of Shell Commands on Linux

Satish Kumar
Updated on 25-Jan-2023 10:46:51

3K+ Views

To read the source code of shell commands on Linux, you can use the command line utility cat or less to view the file. You can also use a text editor such as vi, nano, or emacs to open and edit the code. For example, to view the source code of the ls command, you can use the command − cat /bin/ls If you want to view the source code of a command that is installed from a package manager, you can use package manager command to find the location of the source code. For example, on a Debian-based ... Read More

Search Within Specific File Types Using grep on Linux

Satish Kumar
Updated on 25-Jan-2023 10:43:23

3K+ Views

To search for a specific pattern within a specific file type using the grep command in Linux, you can use the -r option to search recursively through a directory and the -E option to specify the file extension. For example, to search for the word "example" within all text files in the directory "test", you would use the command − grep -r -E 'example' --include='*.txt' test/ This command searches recursively through the "test" directory and its subdirectories, looking for files that have the ".txt" extension and contain the word "example". You can also use find command with -type and ... Read More

fd An Alternative to the Linux find Command

Satish Kumar
Updated on 25-Jan-2023 10:30:32

2K+ Views

The fd command is a popular alternative to the find command in Linux. It is a faster and more user-friendly version of find, and is written in Rust for performance. Some of the key features of fd include the ability to search using regular expressions, a more natural syntax for specifying search parameters, and the ability to search using a specific file extension or name. Installation The fd command can be installed on Linux and macOS using the package manager of your distribution. On Debian based distributions − sudo apt-get install fd-find On Fedora and Centos − sudo yum ... Read More

Guide to Generate Random Numbers in Linux

Satish Kumar
Updated on 25-Jan-2023 10:24:42

9K+ Views

In Linux, you can generate random numbers using the random or urandom files in the /dev directory, which are special files that generate random data. To generate a random number between 0 and 32767, you can use the command echo $((RANDOM)). To generate a random number within a specific range, you can use the command echo $((RANDOM%range+min)), where range is the size of the range and min is the minimum value of the range. Another way to generate random numbers in Linux is using the openssl command. The command openssl rand -base64 6 will generate a random base64 encoded string ... Read More

Remove Lines Which Appear in File B From Another File A in Linux

Satish Kumar
Updated on 24-Jan-2023 19:48:17

4K+ Views

You can use the grep command in Linux to remove the lines from file A that appear in file B. The basic syntax is − grep -v -f fileB.txt fileA.txt > outputFile.txt This command uses the -v option to invert the match, so that it returns lines that do not match those in file B. The -f option specifies the file containing the patterns to match. The output is redirected to a new file called outputFile.txt. Alternatively, you can use sed command sed -i '/$(grep -f fileB.txt fileA.txt)/d' fileA.txt This command uses the -i option to edit the ... Read More

Running Multi-Line Shell Code at Once From Single Prompt

Satish Kumar
Updated on 24-Jan-2023 19:47:32

16K+ Views

You can run multi-line shell code at once by using a shell script or by using a command line tool such as the bash or sh command to execute the code in a single prompt. To create a shell script, you can use a text editor to write the code and save it with a .sh file extension. For example, you can create a file called "script.sh" and add the following code − #!/bin/bash echo "Hello, World!" echo "This is a shell script." Then you can run the script by using the command bash script.sh or sh script.sh. Another ... Read More

Running Script or Command as Another User in Linux

Satish Kumar
Updated on 24-Jan-2023 19:46:40

18K+ Views

There are several ways to run a script or command as another user in Linux. One way is to use the "su" command, which stands for "switch user." For example, to run a command as the user "john, " you would use the following syntax: "su john -c 'command'" Another way to run a command as another user is to use the "sudo" command, which stands for "superuser do." This command allows a user with proper permissions to run a command with the privileges of another user, typically the root user. For example, to run a command as the root ... Read More

Advertisements