Sandra Henry-Stocker

Author Archives: Sandra Henry-Stocker

Splitting files on Linux by context

The csplit command is unusual in that allows you to split text files into pieces based on their content. The command allows you to specify a contextual string and use it as a delimiter for identifying the chunks to be saved as separate files.As an example, if you wanted to separate diary entries into a series of files each with a single entry, you might do something like this.$ csplit -z diary '/^Dear/' '{*}' 153 123 136 In this example, "diary" is the name of the file to be split. The command is looking for lines that begin with the word "Dear" as in "Dear Diary" to determine where each chunk begins. The -z option tells csplit to not bother saving files that would be empty.To read this article in full, please click here

Splitting files on Linux by context

The csplit command is unusual in that allows you to split text files into pieces based on their content. The command allows you to specify a contextual string and use it as a delimiter for identifying the chunks to be saved as separate files.As an example, if you wanted to separate diary entries into a series of files each with a single entry, you might do something like this.$ csplit -z diary '/^Dear/' '{*}' 153 123 136 In this example, "diary" is the name of the file to be split. The command is looking for lines that begin with the word "Dear" as in "Dear Diary" to determine where each chunk begins. The -z option tells csplit to not bother saving files that would be empty.To read this article in full, please click here

New Year’s resolutions for Linux sysadmins in 2022

As the new year gets off to a start, it's always a good idea to commit to some changes that might improve your life or make your work more rewarding. So, here are some suggestions for Linux sysadmin resolutions for 2022.Learn some new commands Even after using Linux for more than 30 years, I often find myself discovering some command that I didn't know about or didn't realize how much I could do with it. 2021 was the first year that I used the cheat command or used the --help option for commands more often that I read their man pages. I also started using the bpytop command fairly often. And, whenever I ran across a command I wasn't previously familiar with, I took the time to look it up, install it (if needed) on one or more of my Linux systems and play with it. Considering that I'm seeing nearly 2,000 files just in /usr/bin on my Fedora system, I'm not surprised that, even after 30+ years, I'm not familiar with all of them.To read this article in full, please click here

New Year’s resolutions for Linux sysadmins in 2022

As the new year gets off to a start, it's always a good idea to commit to some changes that might improve your life or make your work more rewarding. So, here are some suggestions for Linux sysadmin resolutions for 2022.Learn some new commands Even after using Linux for more than 30 years, I often find myself discovering some command that I didn't know about or didn't realize how much I could do with it. 2021 was the first year that I used the cheat command or used the --help option for commands more often that I read their man pages. I also started using the bpytop command fairly often. And, whenever I ran across a command I wasn't previously familiar with, I took the time to look it up, install it (if needed) on one or more of my Linux systems and play with it. Considering that I'm seeing nearly 2,000 files just in /usr/bin on my Fedora system, I'm not surprised that, even after 30+ years, I'm not familiar with all of them.To read this article in full, please click here

Using the timedatectl command to control your Linux time and time zone

The timedatectl command allows you to both query and change the system clock and its settings on Linux systems.To display the current settings, use the command by itself—with no arguments. You should see something like this:[Get regularly scheduled insights by signing up for Network World newsletters.] $ timedatectl Local time: Thu 2021-12-16 11:12:31 EST Universal time: Thu 2021-12-16 16:12:31 UTC RTC time: Thu 2021-12-16 16:12:31 <; real time clock Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern time zone). NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In this case, the RTC it is not set to the local time zone.To read this article in full, please click here

Using the timedatectl command to control your Linux time and time zone

The timedatectl command allows you to both query and change the system clock and its settings on Linux systems.To display the current settings, use the command by itself—with no arguments. You should see something like this:[Get regularly scheduled insights by signing up for Network World newsletters.] $ timedatectl Local time: Thu 2021-12-16 11:12:31 EST Universal time: Thu 2021-12-16 16:12:31 UTC RTC time: Thu 2021-12-16 16:12:31 <; real time clock Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern time zone). NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In this case, the RTC it is not set to the local time zone.To read this article in full, please click here

Timedatectl can control your Linux time and time zone

The timedatectl command allows you to both query and change the system clock and its settings on Linux systems.To display the current settings, use the command by itself—with no arguments. You should see something like this:[Get regularly scheduled insights by signing up for Network World newsletters.] $ timedatectl Local time: Thu 2021-12-16 11:12:31 EST Universal time: Thu 2021-12-16 16:12:31 UTC RTC time: Thu 2021-12-16 16:12:31 <; real time clock Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern US time zone). NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In this case, the RTC it is not set to the local time zone.To read this article in full, please click here

Timedatectl can control your Linux time and time zone

The timedatectl command allows you to both query and change the system clock and its settings on Linux systems.To display the current settings, use the command by itself—with no arguments. You should see something like this:[Get regularly scheduled insights by signing up for Network World newsletters.] $ timedatectl Local time: Thu 2021-12-16 11:12:31 EST Universal time: Thu 2021-12-16 16:12:31 UTC RTC time: Thu 2021-12-16 16:12:31 <; real time clock Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern US time zone). NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In this case, the RTC it is not set to the local time zone.To read this article in full, please click here

Looking at Linux disk usage with the ncdu command

The ncdu command provides a useful and convenient way to view disk usage. The name stands for "NCurses disk usage". This means that it's based on ncurses which, like curses, is a terminal control library used on Unix/Linux systems. The curses part of each name is a pun on "cursor" or "cursor optimization" and is unrelated to the use of foul language.You can think of ncdu as a disk usage analyzer with an ncurses interface. It can be especially useful when looking for disk-space hogs on a remote server for which you don't have access to a graphical interface.[Get regularly scheduled insights by signing up for Network World newsletters.] To use ncdu, you can just type "ncdu", but what you will see depends on where you have positioned yourself in the file system as it reports the space used by files and directories in that location.To read this article in full, please click here

Looking at Linux disk usage with the ncdu command

The ncdu command provides a useful and convenient way to view disk usage. The name stands for "NCurses disk usage". This means that it's based on ncurses which, like curses, is a terminal control library used on Unix/Linux systems. The curses part of each name is a pun on "cursor" or "cursor optimization" and is unrelated to the use of foul language.You can think of ncdu as a disk usage analyzer with an ncurses interface. It can be especially useful when looking for disk-space hogs on a remote server for which you don't have access to a graphical interface.[Get regularly scheduled insights by signing up for Network World newsletters.] To use ncdu, you can just type "ncdu", but what you will see depends on where you have positioned yourself in the file system as it reports the space used by files and directories in that location.To read this article in full, please click here

Using whois/jwhois on Linux

The whois and jwhois commands allow you to retrieve a lot of information on Internet domains--likely a lot more than you might imagine. Here's how these commands work and how they can be useful.To get started, you probably already use nslookup to check on domain names. When you do, you'll see output like this:$ nslookup networkworld.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: networkworld.com Address: 151.101.2.165 Name: networkworld.com Address: 151.101.66.165 Name: networkworld.com Address: 151.101.194.165 Name: networkworld.com Address: 151.101.130.165 The nslookup command queries name servers, so its output provides IP addresses for the queried domain and verifies the domain name is valid, but whois commands provide extensive details on the domain registration, domain status, responsible organizations, their locations, etc., giving you a lot more insight into domains.To read this article in full, please click here

Using whois/jwhois on Linux

The whois and jwhois commands allow you to retrieve a lot of information on Internet domains--likely a lot more than you might imagine. Here's how these commands work and how they can be useful.To get started, you probably already use nslookup to check on domain names. When you do, you'll see output like this:$ nslookup networkworld.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: networkworld.com Address: 151.101.2.165 Name: networkworld.com Address: 151.101.66.165 Name: networkworld.com Address: 151.101.194.165 Name: networkworld.com Address: 151.101.130.165 The nslookup command queries name servers, so its output provides IP addresses for the queried domain and verifies the domain name is valid, but whois commands provide extensive details on the domain registration, domain status, responsible organizations, their locations, etc., giving you a lot more insight into domains.To read this article in full, please click here

Use dmseg to check your Linux system’s kernel message buffer

The dmesg command displays the content of the kernel's message buffer since the system's most recent boot. It displays a lot of details on how the system is working and problems it might be running into that you won't normally see. That can be a lot of data, but there are several tricks for paring it down.For example, Even though the system queried below has only been up a little more than three days, it's collected more than a thousand lines of data.$ dmesg | wc -l 1034 Linux security: Cmd provides visibility, control over user activity [Get regularly scheduled insights by signing up for Network World newsletters.] If you type only dmesg, you will see all available data. Sudo access is not required. You can also pipe the output of dmesg to the more and less commands to scan through it or simply pipe the output to grep, but the command itself provides a lot of options for selecting the most relevant information from the file.To read this article in full, please click here

Use dmseg to check your Linux system’s kernel message buffer

The dmesg command displays the content of the kernel's message buffer since the system's most recent boot. It displays a lot of details on how the system is working and problems it might be running into that you won't normally see. That can be a lot of data, but there are several tricks for paring it down.For example, Even though the system queried below has only been up a little more than three days, it's collected more than a thousand lines of data.$ dmesg | wc -l 1034 Linux security: Cmd provides visibility, control over user activity [Get regularly scheduled insights by signing up for Network World newsletters.] If you type only dmesg, you will see all available data. Sudo access is not required. You can also pipe the output of dmesg to the more and less commands to scan through it or simply pipe the output to grep, but the command itself provides a lot of options for selecting the most relevant information from the file.To read this article in full, please click here

Shortcuts for adding multiple lines of text to files on Linux

There are a number of ways to add text to files on Linux systems without having to open an editor, such as the echo and printf commands. On the other hand, when you need to add A LOT of text, the technique you use can make the job tedious or a piece of cake.This post describes some of the commands you can use and the problems and benefits you can expect.Also see: How to loop forever in bash on LinuxThe echo commands append lines of text to existing files in a straightforward way:To read this article in full, please click here

Shortcuts for adding multiple lines of text to files on Linux

There are a number of ways to add text to files on Linux systems without having to open an editor, such as the echo and printf commands. On the other hand, when you need to add A LOT of text, the technique you use can make the job tedious or a piece of cake.This post describes some of the commands you can use and the problems and benefits you can expect.Also see: How to loop forever in bash on LinuxThe echo commands append lines of text to existing files in a straightforward way:To read this article in full, please click here

Using the script command on Linux to record command line activity

The Linux script command has been around for ages and provides a simple but useful service. It lets you record command line activity – both input and output. This can be very helpful in troubleshooting problems or verifying what was done later by reviewing the commands that were run along with their output.Even if you've used the script command time to time, it offers more options than many of us realize. In this post, we will look at the simplest use of script and some of the options that can make it even more useful.The easiest way to use the script command is simply to type "script" in the terminal window and press ^d when you want to stop the recording. The output, by default, will be saved in a file called "typescript". You will see the file name that is used in the first line of output.To read this article in full, please click here

Using the script command on Linux to record command line activity

The Linux script command has been around for ages and provides a simple but useful service. It lets you record command line activity – both input and output. This can be very helpful in troubleshooting problems or verifying what was done later by reviewing the commands that were run along with their output.Even if you've used the script command time to time, it offers more options than many of us realize. In this post, we will look at the simplest use of script and some of the options that can make it even more useful.The easiest way to use the script command is simply to type "script" in the terminal window and press ^d when you want to stop the recording. The output, by default, will be saved in a file called "typescript". You will see the file name that is used in the first line of output.To read this article in full, please click here

Monitoring Linux system resources with bpytop

The bpytop tool is similar to other performance monitoring tools available for Linux systems like top, iotop, htop, bashtop etc. It’s a terminal-based resource monitor that works efficiently and is visually appealing.The tool was ported from bashtop and rewritten in Python, so you need to have Python—version 3.6 or later—installed on your system to use it. (The “bpy” portion of the name undoubtedly stands for “bash Python”.)If you already have Python installed on your system, you can check the version using one of these sets of commands:Fedora Linux Mint ====== ========== $ which python $ which python3 /usr/bin/python /usr/local/bin/python3 $ python -V $ python3 -V Python 3.9.7 Python 3.8.10 Both systems shown are running Python3, but the Fedora system has /usr/bin/python set up as a symbolic link to python and the other system does not. So, they’re both using Python3.To read this article in full, please click here

Monitoring Linux system resources with bpytop

The bpytop tool is similar to other performance monitoring tools available for Linux systems like top, iotop, htop, bashtop etc. It’s a terminal-based resource monitor that works efficiently and is visually appealing.The tool was ported from bashtop and rewritten in Python, so you need to have Python—version 3.6 or later—installed on your system to use it. (The “bpy” portion of the name undoubtedly stands for “bash Python”.)If you already have Python installed on your system, you can check the version using one of these sets of commands:Fedora Linux Mint ====== ========== $ which python $ which python3 /usr/bin/python /usr/local/bin/python3 $ python -V $ python3 -V Python 3.9.7 Python 3.8.10 Both systems shown are running Python3, but the Fedora system has /usr/bin/python set up as a symbolic link to python and the other system does not. So, they’re both using Python3.To read this article in full, please click here

1 3 4 5 6 7 25