Creating a script on a Unix or Linux system can be dead easy or surprisingly complex; it all depends on how much you’re trying to get the script to do. In this post, we look at scripting basics—at how to get started if you have never built a script before.Identifying the shell
Unix and Linux systems today have a number of shells that you can use. Each shell is a command interpreter. It reads commands and sends them to the kernel for processing.[Get regularly scheduled insights by signing up for Network World newsletters.]
Bash is one of the most popular, but there’s also zsh, csh, tcsh and korn. There’s even one called fish that can be especially nice for Linux beginners because of its helpful command auto-completion options. To determine which shell you are using, use this command:To read this article in full, please click here
Creating a script on a Unix or Linux system can be dead easy or surprisingly complex; it all depends on how much you’re trying to get the script to do. In this post, we look at scripting basics—at how to get started if you have never built a script before.Identifying the shell
Unix and Linux systems today have a number of shells that you can use. Each shell is a command interpreter. It reads commands and sends them to the kernel for processing.[Get regularly scheduled insights by signing up for Network World newsletters.]
Bash is one of the most popular, but there’s also zsh, csh, tcsh and korn. There’s even one called fish that can be especially nice for Linux beginners because of its helpful command auto-completion options. To determine which shell you are using, use this command:To read this article in full, please click here
There are a number of ways that you can create PDFs on a Linux system. You can use an application like LibreOffice or OpenOffice, or you can take advantage of any of a number of commands that can generate PDFs from text files or from a group of other file formats. There are also a number of ways that you can merge a group of PDFs into a single PDF file.Why PDFs?
PDF is often the preferred format for files that you need to share with others or archive. This is because PDF is an open file format, which makes sharing these files between diverse systems and devices possible.Using LibreOffice or OpenOffice
Both LibreOffice and OpenOffice can export files as PDFs. You can open an existing document or create a new document and export it as a PDF. OpenOffice's Export as PDF… and LibreOffice's Export As => Export as PDF… will do what is required to convert your file.To read this article in full, please click here
There are a number of ways that you can create PDFs on a Linux system. You can use an application like LibreOffice or OpenOffice, or you can take advantage of any of a number of commands that can generate PDFs from text files or from a group of other file formats. There are also a number of ways that you can merge a group of PDFs into a single PDF file.Why PDFs?
PDF is often the preferred format for files that you need to share with others or archive. This is because PDF is an open file format, which makes sharing these files between diverse systems and devices possible.Using LibreOffice or OpenOffice
Both LibreOffice and OpenOffice can export files as PDFs. You can open an existing document or create a new document and export it as a PDF. OpenOffice's Export as PDF… and LibreOffice's Export As => Export as PDF… will do what is required to convert your file.To read this article in full, please click here
The Linux command line allows your system to remember commands that you use—up to a limit set by your HISTSIZE variable. Since each user’s HISTSIZE is generally set to 1000, that means Linux can remember the last 1000 commands you entered and make it easy to reuse them without retyping them.Unless you configure your history settings differently, all of your commands will be remembered. You can put some restrictions on that behavior if you like. For example, you might not want to save every command you use to read a man page or every time you type pwd to ask where you’re currently sitting in the file system. How to restrict the commands that are remembered and which are not is covered here.To read this article in full, please click here
The Linux command line allows your system to remember commands that you use—up to a limit set by your HISTSIZE variable. Since each user’s HISTSIZE is generally set to 1000, that means Linux can remember the last 1000 commands you entered and make it easy to reuse them without retyping them.Unless you configure your history settings differently, all of your commands will be remembered. You can put some restrictions on that behavior if you like. For example, you might not want to save every command you use to read a man page or every time you type pwd to ask where you’re currently sitting in the file system. How to restrict the commands that are remembered and which are not is covered here.To read this article in full, please click here
Commands for comparing files have proliferated since the early days of Linux. In this post, we'll look at a suite of commands available for comparing files and highlight the advantages that some of the newer ones provide.diff
One of the oldest and still popular commands for detecting and reporting on file differences is the diff command. Comparing two lists of meeting attendees, the diff command will simply and clearly show you the differences.$ diff attendance-2020 attendance-2021
10,12c10
< Monroe Landry
< Jonathon Moody
< Donnell Moore
---
> Sandra Henry-Stocker
Only the lines that are different are displayed. The output precedes lines that are only in the first file with < and those only in the second file with >.To read this article in full, please click here
Commands for comparing files have proliferated since the early days of Linux. In this post, we'll look at a suite of commands available for comparing files and highlight the advantages that some of the newer ones provide.diff
One of the oldest and still popular commands for detecting and reporting on file differences is the diff command. Comparing two lists of meeting attendees, the diff command will simply and clearly show you the differences.$ diff attendance-2020 attendance-2021
10,12c10
< Monroe Landry
< Jonathon Moody
< Donnell Moore
---
> Sandra Henry-Stocker
Only the lines that are different are displayed. The output precedes lines that are only in the first file with < and those only in the second file with >.To read this article in full, please click here
If you need to generate a list of names and addresses to test an application or a script that you're working on, Linux can make that surprisingly easy. There's a command called "rig" that will create name, address and phone number listings. As far as I can tell, out of the box, it only works with U.S. addresses and area codes. However, if this is indeed the case, you might be able to work around this problem.To use the rig command, you can just type "rig" on the command line, and a single name and address will be generated. You will see something like this:$ rig
Mavis English
1015 Tulip St
Anderson, IN 46018
(317) xxx-xxxx
To generate a list with many addresses, use the -c option and specify the number of addresses that you want to see.To read this article in full, please click here
If you need to generate a list of names and addresses to test an application or a script that you're working on, Linux can make that surprisingly easy. There's a command called "rig" that will create name, address and phone number listings. As far as I can tell, out of the box, it only works with U.S. addresses and area codes. However, if this is indeed the case, you might be able to work around this problem.To use the rig command, you can just type "rig" on the command line, and a single name and address will be generated. You will see something like this:$ rig
Mavis English
1015 Tulip St
Anderson, IN 46018
(317) xxx-xxxx
To generate a list with many addresses, use the -c option and specify the number of addresses that you want to see.To read this article in full, please click here
In this post, we examine a bash script that takes a string of letters, rearranges them in every possible way and checks each permutation to identify those that are English words. In the process, we'll take a close look at the script and calculate how hard it might have to work.Note that, in the algorithm used, each letter arrangement must use all of the letters in the string provided. Words formed by substrings are not considered.How to loop forever in bash on Linux
First, the script expects the scrambled string to be provided as an argument and prompts for it if none is provided. It then checks out each arrangement of letters to find those that exist in the system's words file – in this case, that's /usr/share/dict/words. Here are the first lines in the script:To read this article in full, please click here
In this post, we examine a bash script that takes a string of letters, rearranges them in every possible way and checks each permutation to identify those that are English words. In the process, we'll take a close look at the script and calculate how hard it might have to work.Note that, in the algorithm used, each letter arrangement must use all of the letters in the string provided. Words formed by substrings are not considered.How to loop forever in bash on Linux
First, the script expects the scrambled string to be provided as an argument and prompts for it if none is provided. It then checks out each arrangement of letters to find those that exist in the system's words file – in this case, that's /usr/share/dict/words. Here are the first lines in the script:To read this article in full, please click here
Linux users should immediately patch a serious vulnerability to the sudo command that, if exploited, can allow unprivileged users gain root privileges on the host machine.Called Baron Samedit, the flaw has been “hiding in plain sight” for about 10 years, and was discovered earlier this month by researchers at Qualys and reported to sudo developers, who came up with patches Jan. 19, according to a Qualys blog. (The blog includes a video of the flaw being exploited.)To read this article in full, please click here
Linux users should immediately patch a serious vulnerability to the sudo command that, if exploited, can allow unprivileged users gain root privileges on the host machine.Called Baron Samedit, the flaw has been “hiding in plain sight” for about 10 years, and was discovered earlier this month by researchers at Qualys and reported to sudo developers, who came up with patches Jan. 19, according to a Qualys blog. (The blog includes a video of the flaw being exploited.)To read this article in full, please click here
Any time you have a text file on a Linux system that you want to keep private regardless of the privileges that other users with accounts on the system may have, you can resort to encryption. One easy way to do this is to use a feature that is built into the vim editor. You will have to provide a password that will you then need to remember or store in a password safe, but the process is straightforward. The file name will not be changed in any way, and the content of the file can be recovered in much the same way that it was encrypted.To begin, let's say that we have a file that begins like this:$ head -3 mysecret
I feel the need to put my deepest darkest secret into a text file on my Linux
system. While this likely isn't common practice, I'm not sure that I can trust
anyone with it. But a penguin? That's a different story! So here goes ...
Now, not wanting to risk your deepest darkest secret to fellow users, you use vim with its -x (encryption) option.To read this article in full, please click here
Any time you have a text file on a Linux system that you want to keep private regardless of the privileges that other users with accounts on the system may have, you can resort to encryption. One easy way to do this is to use a feature that is built into the vim editor. You will have to provide a password that will you then need to remember or store in a password safe, but the process is straightforward. The file name will not be changed in any way, and the content of the file can be recovered in much the same way that it was encrypted.To begin, let's say that we have a file that begins like this:$ head -3 mysecret
I feel the need to put my deepest darkest secret into a text file on my Linux
system. While this likely isn't common practice, I'm not sure that I can trust
anyone with it. But a penguin? That's a different story! So here goes ...
Now, not wanting to risk your deepest darkest secret to fellow users, you use vim with its -x (encryption) option.To read this article in full, please click here
Any time you have a text file on a Linux system that you want to keep private regardless of the privileges that other users with accounts on the system may have, you can resort to encryption. One easy way to do this is to use a feature that is built into the vim editor. You will have to provide a password that will you then need to remember or store in a password safe, but the process is straightforward. The file name will not be changed in any way, and the content of the file can be recovered in much the same way that it was encrypted.To begin, let's say that we have a file that begins like this:$ head -3 mysecret
I feel the need to put my deepest darkest secret into a text file on my Linux
system. While this likely isn't common practice, I'm not sure that I can trust
anyone with it. But a penguin? That's a different story! So here goes ...
Now, not wanting to risk your deepest darkest secret to fellow users, you use vim with its -x (encryption) option.To read this article in full, please click here
There are a lot of commands available on Linux for looking at network settings and connections. In today's post, we're going to run through some very handy commands and see how they work.To read this article in full, please click here(Insider Story)
There are a lot of commands available on Linux for looking at network settings and connections. In today's post, we're going to run through some very handy commands and see how they work.To read this article in full, please click here(Insider Story)
One convenient way to list details about user logins on a Linux system is to use the lslogins command. You'll get a very useful and nicely formatted display that includes quite a few important details.On my system and likely most others, user accounts will start with UID 1000. To list just these accounts rather than include all of the service accounts like daemon, mail and syslog, add the -u option as shown in the example below.$ sudo lslogins -u
UID USER PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS 0 root 151 0 0 root 1000 shs 68 0 0 12:35 Sandra H-S
1001 nemo 0 0 0 2021-Jan05 Nemo Demo,,,
1002 dbell 0 0 1 Dory Bell
1003 shark 2 0 0 7:15 Sharon Hark
1004 tadpole 0 0 0 2020-Dec05 Ted Pole
1005 eel 0 0 0 2021-Jan11 Ellen McDay
1006 bugfarm 0 0 0 2021-Jan01 Bug Farm
1008 dorothy 0 0 1 Dorothy Reuben
1012 jadep 0 0 1 2021-Jan04 Jade Jones
1013 myself 0 0 0 2021-Jan12 My Self
1014 marym 0 0 0 2020-Mar20 Mary McShea
1017 gijoe 0 0 0 GI Joe
65534 nobody 0 0 1 nobody
What the lslogins command does is grab Continue reading