How to access collaborative cheatsheets for console commands
Access collaborative cheatsheets for console commands in command-line.
Access collaborative cheatsheets for console commands in command-line.
Extract INI sections and keys from the command-line.
JSONify apt history for easier parsing in scripts using jc command-line utility.
Prompt for a login name on serial tty device.
Check the zone serial number to verify that every secondary name server updated its copy of the zone file.
Change the file owner and indirectly file group to the user’s login group.
Determine where DNS is hosted using administrator’s email address.
Install Perl module non-interactively.
Retrieve MAC addresses of network interfaces.
Exclude starting point when searching for directories.
Display static information about the filesystems stored in /etc/fstab configuration file.
Use date command to obtain current week number.
Create empty tar archive.
Find symlinks to a specific file.
Download system updates.
Execute single or multiple commands from the standard input and store results using JSON file.
Execute multiple commands from the standard input in parallel using xargs.
Alter file ownership and permissions with feedback information using verbose mode to see what exactly has changed.
Convert table to JSON format using nothing more than basic commands.
Find processes related to a specific connection.
Automatically clear APT cache after each operation.
Execute command as regular user.
Install packages non-interactively using apt-get utility.
Open GNU dbm database file.
Match whole word using grep.
Find device by the major and minor numbers.
Determine mountpoint for specific file or directory.
Display directory contents sorted by time.
Discover hosts on local network to quickly locate new devices.
Perform reverse DNS lookup using dig command-line utility.
List outgoing connections.
Filter specific IP address.
Display default gateway.
Search for multiple patterns in a file using awk.
Repeatedly execute multiple commands in a pipeline.
Display current CPU and memory usage for specific user.
Display directory tree using text or JSON output.
Print the name of each file matched by grep.
This is a simple reminder that you can use basic system utilities to parse text files, extract, filter and concatenate data.
Check IP address of specific domain name using curl utility.
Check the SHA checksum using shell script.
Check the time in a different time zone to determine when the meeting will start whenever you are.
Control the wget dot display to pretty-print retrieval status for large files which proved to be useful inside shell script or CI/CD jobs.
Add or remove user from a group using multiple different utilities.
Detect new group and update environment during live session.
Join a group and update environment during live session.
Monitor multiple log files at once using MultiTail utility.
Inspect firmware update using RACADM command-line utility which provides a scriptable interface for Remote Access Controller.
Display IPv4 address without network utilities.
Inspect remote GnuPG signing key.
Display weather forecast inside terminal using wego application.
Pretty print ping output using prettyping.
Access specific file occurrence in tar archive.
You can directly inspect kernel slab allocator statistics (/proc/slabinfo file) for detailed information on buffer, inode, dentry, or other caches in the Linux kernel, though slabtop utility will sort and pretty-print information in real-time.
Use basic Linux utilities to list file names and their contents.
Use system performance tools for Linux to display process statistics.
Use sponge utility to read standard input and safely write it out to the same file.
I have already described how to strace PHP-FPM processes, but you can also display a strace summary to get detailed information about count time, calls, and errors for each syscall.
Ensure that OpenSSH client uses explicitly configured authentication identity even if authentication agent offers more identities.
Use numfmt command-line utility which is a part of the standard GNU Core Utilities to pretty print decimal or binary numbers.
Inspect and redeploy the master certificate in OpenShift 3.11.
Replacing the router certificate in OpenShift 3.11 is easier than you think.
Use FUSE (filesystem in userspace) to access rdiff-backup repository.
Specify a custom SSH port when using rdiff-backup.
Display, search, create or delete the Kibana index pattern using API.
Use OpenSSL to manage PKCS #12 archive.
Rebuild hawkular metrics after cluster deploy on OpenShift 3.11.
Install OpenShift client 3.11.
Use basic linux command-line utility to calculate real disk capacity.
Determine available authentication methods on the specified OpenSSH server.
Display details for specific OpenSSL cipher, only single one.
Undo fsck operations performed on the Ext4 filesystem.
Reindex directories located in the Ext4 filesystem after removing a huge number of files to optimize directory sizes.
Inspect OpenSSH client configuration to search and display configured hosts.
Expand an existing XFS filesystem on LVM Logical Volume.
Revoke specific key used to perform key-based login with OpenSSH utilizing simple public key revocation list or OpenSSH Key Revocation List (KRL).
Determine which SSH key was used to perform key-based login using public key fingerprint.
Display message before OpenSSH authentication using simple built-in mechanism.
Use dedicated command-line utility to convert various units to different measurement systems.
Use wcs stream meter created by Arno Wagner to display count and rate statistics for data read on standard input.
Keeping SSH authentication agent in sync across multiple servers and terminal multiplexers is not an easy task, but can be solved by using consistent socket names used to connect to the SSH authentication agent.
Parse INI configuration file using Bash shell-script.
Attach to the tmux session over SSH to continue your work.
Store runtime configuration within shell script using a simple but effective method.
Store contents of every tmux pane using a shell script.
Store contents of tmux pane to a file to keep the history or inspect recently executed commands.
I have already described how to inspect a pipeline, but today I will show you how to write a shell script that will help you reconstruct a whole pipeline when all you got is a process ID that is part of the pipeline.
A pipeline is a sequence of multiple commands separated by the control operators. It is easy to understand as long as you see the whole picture, but I will show you how to inspect it when you have a single process ID.
Use bash redirection and process substitution to programmatically distinguish standard error from regular output.
Isolate the problem and strace multiple PHP-FPM (FastCGI Process Manager for PHP) processes to identify the culprit.
Match certificate and its intermediate counterpart by using X.509 key identifier extension.
Use openssl utility to display and verify the certificate chain for a specific domain.
Send output to multiple commands using tee utility and bash process substitution.
Write a simple Bash shell script that will allow you to specify the same option multiple times or provide multiple arguments to a single option.
Use netstat, ss or files inside proc filesystem to count TCP connections.
Generate and print sequences of numbers to perform specific operations using command-line or shell script.
Create a shell script to determine how long a specified remote server or device was offline. It is not designed to substitute monitoring solutions but to determine how long it will take to reboot the server or device. It is using convert seconds to human readable time code to display results.
Query robots.txt using the robots.txt exclusion protocol implementation for Go language.
Configure sysfs during system boot to apply custom configuration in a simple and convenient way
There are certain situations where I disable Intel Turbo Boost, for example to keep fans quiet during the night time.
Capture column from command output and convert it to a row to pass it further.
Check website for broken links using HTTrack website copier.
Copy website for offline browsing using HTTrack website copier.
Pretty print size in bytes using AWK.
Download OpenVPN configuration using public NordVPN API to specific file.
These are easy mistakes to make as the bash builtin read command will terminate with the error exit code on the end-of-file condition and use Internal Field Separator to split the line into words. It is kind of tricky, but it is worth knowing how to deal with such problems.
Display memory used by processes in human-readable form using ps and awk utilities.
Manipulate X clipboard from terminal using xclip utility which is a command line interface to X selections to easily copy and paste text from terminal to GUI applications.
Display your external IP address using public NordVPN API.
Learn how to free dirty objects, page cache, and reclaimable slab objects for troubleshooting or instructional purposes.
Today, I will show you how to get and display user details using a shell script. This work is based on a Python-based solution by David Green and located at bitbucket/nordapi.
Sometimes it is very convenient to define shell function and execute it remotely.
Compare two files byte by byte using cmp file comparison utility.
Inspect Redis internals using UNIX socket and Python script without external dependencies.
Use simple shell function to instantly create known_hosts entries for specified host, including its IP address and remove outdated public host keys.
Global known_hosts file located in /etc/ssh/ssh_known_hosts and user managed ~/.ssh/known_hosts contain known host public keys. Due to its nature these files can contain multiple entries using the same key. It is not a problem, but merging entries using the same key is the first step that is necessary to inspect it visually and to verify host entries.
Disconnect idle SSH clients using built-in client alive mechanism.
Monitor PHP-FPM (FastCGI Process Manager) pool using curl utility, cgi-fcgi application or slightly modified Python script that was used to display PHP-FPM pool information.
Display PHP-FPM (FastCGI Process Manager) pool information using UNIX socket and Python script. I thought it would be easy to write a simple FCGI client. Apparently not, but it was an exciting and rewarding experience.
Display PHP-FPM (FastCGI Process Manager) pool information using command-line utilities like curl or cgi-fcgi.
Match certificate and its private key by comparing the modulus of the certificate to the modulus of the private key.
I have already described how to check external IP address using curl or your own SSH service, but you can also use dig utility to take advantage of the OpenDNS, Google or Akamai DNS service.
Use the find utility to move files based on specific time criteria.
I am surprised that exFAT is not supported out of the box as it is a default filesystem used on SDXC cards. You need to install a FUSE-based implementation to access data on devices using it.
In a blog post a month ago, I described how to use a terminal to display servers recommended by NordVPN, but the same result can be achieved by using public API service. It is not officially documented, so let’s play with it.
Determine what filesystem is mounted where, what is using particular options and how much free space is available.
Use NordVPN command-line utility to easily manage VPN service.
The simplest possible way to create a Debian package is to use defined package metadata and prepared target directory structure.
Control the amount of information printed out to standard error by the dd utility.
Verify static filesystem information defined in the fstab file after applying modifications to ensure that system will boot without any problems. It is especially important in remote locations or places where you cannot easily perform emergency operations.
I have already described a simple way to manually configure Network Manager and automatically import NordVPN servers, so today, I will explain how to pretty print servers recommended by NordVPN using terminal instead of web-browser.
Create a shell script to convert seconds to human-readable time. I have reused part of an old shell script used to pretty-print system uptime to build it, as this code proved to be useful on several occasions.
cal is a nice utility that displays a calendar in the terminal, but there is a small problem that needs to be fixed as it uses Sunday as the start of the week.
Disable onboard WiFi and Bluetooth on Raspberry Pi 3 device.
Very rarely and often by mistake, you can end up with a deleted file that is still used by some process, which is likely writing to it, so the used space cannot be freed.
Sometimes it makes me wonder whether I am inside a chroot environment or not, so let’s check it out.
Define backup backend in HAProxy configuration to choose used backend depending on the number of usable servers.
Download Raspbian image and write it to the SD card using as few commands as possible.
Schedule a one-time task at a specific time or below defined system load using at utility.
Alter password expiry date to force user to change password on next login.
Execute paste utility to merge lines using tab character as a delimiter, expand to convert tabs to spaces, and column to format input into multiple columns.
Extract RPM package on macOS to access its contents, which is especially useful for some old source packages.
Display processes using the most CPU or memory using nothing more than basic Linux utilities.
Create simple artificial package to work around missing dependencies.
Create straightforward shell script to resolve hostname to IPv4/IPv6 address and reuse parts of it for other projects.
Use a shell script to count separate line entries inside a pipe to see how many entries got filtered out. It can be useful in some scenarios, especially for testing.
Recently, I have parsed logs of several applications to generate custom weekly reports. It was a fascinating exercise.
Create the simplest possible meta-package to install multiple software packages at once and quickly set up a familiar environment.
Display reverse dependencies to inspect which packages depend on given application or library.
Perform simple incremental backup using rdiff-backup utility.
There are those rare situations where you do not know the public key required to verify repository signatures but want to add a repository and a public key used to sign it. Hopefully, there is an easy answer to that question.
Install and configure localepurge package, which provides a fancy shell script to recover disk space used by useless localizations.
Configure and enable command-line tab completion for known SSH hosts to ease day-to-day operations. You do not need to configure or enable this on Debian-based distributions, but it is good to know how to do this as you will never know when it will come in handy. This article is an extension of adding the SSH menu to the Unity launcher blog post.
Use Content-Disposition HTTP response header to determine filename and use it to store downloaded file.
Configuring and using additional repositories requires APT public key management to validate the Release file and downloaded packages.
Find a symbolic link by the target name. It sounds simple and it definitely is.
Determine how long it would take to copy data between directories.
Verify file integrity using the GnuPG signature without touching your local GnuPG configuration.
Compute SHA message digest of a file to verify that its contents have not been altered.
Create a shell script for a cron job with hidden debug information shown only when executed inside the terminal.
Logrotate does not support hourly schedule, but this is an easy task to accomplish.
Use find and grep commands to search for directories that contain one or multiple files with specific content.
Display dependencies to inspect which packages are required for a given application.
Enable HTTPS (Hypertext Transfer Protocol Secure) for package managers using libapt-pkg library.
Display upcoming events in the Nextcloud calendar using a custom shell script by extending the earlier ideas.
Display upcoming events in the Nextcloud calendar using a text-based terminal emulator because it is fun and challenging.
Dynamically choose HAProxy backend depending on the HTTP host header, Lua programming language and environment variable.
Detect and log changes in the list of mounted filesystems (/proc/self/mountinfo file).
Use GNU Bourne-Again SHell builtin or standalone time command to determine process execution time.
Use cron service to execute additional commands as the specified user during system startup.
Recently, I have moved my personal source code to GitLab. It rendered self-hosted git repository at repository.sleeplessbeastie.eu obsolete, so I have created simple redirection on HAProxy load balanced to cover this specific case.
Store LeaseWeb data traffic in OpenTSDB time series database using Python script, LeaseWeb API v2 and Python client to OpenTSDB.
Define and use a variable to dynamically choose HAProxy backend depending on the URL parameter, HTTP header field, and cookie value.
LeaseWeb released a new version of API that will deprecate the old one, so it is the perfect time to update the Python script using v1 api and switch to API v2 before May 31.
Securely change user password using shell script to automate this task on these rare occasions.
I have described the differences between the old and new free output format, so now I want to mention how to execute the former free version on Debian Stretch using LD_LIBRARY_PATH environment variable to temporarily substitute a different library for this particular execution.
Block particular IP addresses on HAProxy load balancer using simple Access Control List.
Use essential openssl utility to quickly determine if your web-server still supports deprecated TLS 1.0 protocol.
Define basic authentication on HAProxy load balancer to limit access to specific backends.
Use dpkg to pretty print package dependencies.
Define allowed HTTP methods on HAProxy load balancer using simple Access Control Lists.
Use encrypted passwords to automatically set up users using configuration management tools like Puppet or Ansible.
Check locally stored SSL certificate using essential utilities like openssl and curl. This knowledge is especially useful when you want to prepare an SSL certificate for a load balancer.
Debian Wheezy provides an ancient version of pip utility for installing Python packages. To put it very simply, it does not work anymore as it is not using HTTPS protocol, but fortunately this issue can be quickly fixed.
Create a certificate signing request and use it to generate an SSL certificate. I strongly suggest reading my two earlier blog posts about self-signed SSL certificates and private keys as these contain useful information. I will describe three different ways to generate a certificate signing request.
The free utility is used to display the amount of free and used memory in the system. Debian Stretch provides an upgraded package. The output format has changed, and available memory is calculated using a different method, so let’s see what we can do with these modifications at this moment.
Generate private key for an SSL certificate and verify its consistency.
Query APT configuration to inspect specific options or create universal Debian utilities.
It is very useful to know how to distinguish between different GnuPG public key files.
There are many different ways to verify IPv4 address inside a shell script, but many of these are complicated or incomplete. I will describe a simple and verbose way to check IPv4 address using ipcalc utility.
Display IPv4 network information for given address and netmask. Split networks, calculate subnetworks and supernetworks and convert address range.
LeaseWeb provides an API that can be used to request information about servers and perform some maintenance tasks like update reverse DNS entries, null route IP addresses, reboot specific server or launch rescue/reinstallation process. I will show you how to request and display identifiable information about servers in each location including data traffic details.
I am using a simple shell script to manage OpenSSL known_hosts file as it requires many small updates due to constantly changing host keys on a dynamic virtual server.
Recently, I tried to update uwsgi package on Ubuntu Xenial, but received an error about broken package. It looks like the mentioned package was pushed to the repository before its dependencies. This issue is thoroughly described in <a href=“https://bugs.launchpad.net/ubuntu/+source/uwsgi/+bug/1719363" target=_blank” rel=“external”>#1719363 bug report.
Backports repository provides packages for stable system that are recompiled from testing or unstable distribution. It is important to know that these packages are provided as is without any security support guarantee.
Debian Stretch provides gnupg in minimal installation as the package priority is set to important. The command is fully operational, but it requires dirmngr to perform network operations for managing and downloading certificates.
Remove package dependencies that are now no longer needed and configure the system to perform this task automatically.
The init-system-helpers package that provides a helper tools for all init systems is not available in primary Debian Wheezy repositories. You need to use wheezy-backports repository to install it on that operating system.
Keeping an eye on a constantly changing APT cache can be quite tedious, so automate this task and free up your time to focus on other projects.
This is just a brief note on how to reverse a text file. It is not really useful for anything other than fun, but it is stuck in my head, so I need to write it down.
Clear the APT cache to reclaim disk space used by the downloaded packages.
Disable APT cache to conserve disk space on a small Debian based embedded system or a custom-built live USB system that can be easily booted.
I am an enthusiast of the uWSGI project. You are still not limited to it as you can use fcgiwrap, a very lightweight and straightforward FastCGI wrapper for CGI scripts that do not require additional configuration.
Nextcloud is a handy self hosted web-based application that can be used to store files, contacts and calendars. It provides the desktop and mobile client. In addition, it supports Web Distributed Authoring and Versioning protocol, so let’s mount a WebDAV share.
I am using curl to verify redirects and display real destination URL, and you should try it too.
It is time to mention about simple sequential or simultaneous upgrade process on lxd guests. It is adapted to Debian-like operating systems using apt as I am using these daily.
Use curl utility to verify the HTTP response code for the given URL.
Stop running away from this, request and assign an IPv6 address to an external interface to make content available over both IPv4 and IPv6.
Use a defined webhook to post a message from the command-line as a parameter, standard input, or a file into Slack/Mattermost. Take advantage of colors, icons, and markdown to enhance your message.
Today, I will create a simple proof of concept shell script to display the message provided from standard input or parameter. It could be used as a template to write shell scripts that can be executed in a pipe or as a standalone application.
Two years ago, I described a simple way to display established TCP connections using ss command. Today I will use lsof and gawk to pretty print network connections.
Perform test whether a number is a prime using command-line factor utility.
It is widespread to display and store command output using tee utility, but taking full advantage of it requires applying a slightly different error catching strategy.
Create a simple shell script that will read user message as a parameter or directly from standard input when used in the pipeline.
There is no better utility than wget to recursively download interesting files from the depths of the internet. I will show you why that is the case.
Check current status of Debian Common Vulnerabilities and Exposures using simple python script and Security Bug Tracker.
Today, I will share a simple way to print an IP address assigned to the specified interface.
Today, I will describe how to display environment variables associated with the running process.
There are rare cases when known hosts file becomes corrupted, so basic ssh utilities fail within custom built shell scripts due to ~/.ssh/known_hosts is not a valid known_hosts file error.
Display established connections broken down by a host.
Identify and print processes using swap space to get a better understanding of the Linux operating system.
I described a simple way to generate self-signed SSL certificate using command-line two weeks ago. So, today I will share very useful trick for MacOS users which is a shell script to import self-signed certificate to macOS system keychain using command-line.
Today I will show you how to quickly generate ready to use self-signed SSL certificate for nginx HTTP server using command-line. It is a very handy ability that will allow you to perform various tasks locally or in home laboratory without touching dedicated certificates.
There are circumstances when you want to ensure a particular package version during the setup process. I will show you a simple method to verify the package version suitable for sourcing into a shell script.
There are at least several ways to determine when the process was started to help you investigate and trace potential issues. I will briefly introduce four different methods to choose the most useful one.
There are many applications that share the same source package, so I will show three different ways to print the name of the source package.
Knowing how to determine the last time package index files were updated can be beneficial when you least expect it. It is not something used every day but can be used to monitor or verify when apt-get update command was executed.
It is very easy to upgrade the whole Debian system, but you can also upgrade only selected packages and skip the rest.
Many years ago I wrote How to display available updates blog post which mainly related to Debian Wheezy. Today I want to extend it by a neat console friendly utility available in Debian Jessie since the milestone apt release thanks to Michael Vogt.
I have already described a straightforward way to automatically login user at the console without touching the graphical user interface using Debian Wheezy, so today I will post an update for Debian Jessie as the whole process has changed considerably.
Today, I will illustrate a simple way to check for specific command inside a shell script, which is quite simple as it uses only shell built-in command utility.
Today, I want to briefly describe a simple way to check for a specific package inside a shell script.
It was almost three years ago when I wrote about manual pages. Moving forward, I want to share a simple and useful shell script to search through manual pages.
It is nothing fancy, but there are situations where it is beneficial to know how to identify and inspect command before execution.
It is easy to get names of distinct Debian releases as you can always examine these on the Debian Releases web page. I will do something more interesting and demonstrate how to do that using a simple shell script.
I will show you how to generate a random password using the OpenSSL utility, standard command-line utilities, Password Generator (pwgen), and Automated Password Generator (APG).
From time to time I have to update passwords used to secure private keys to keep myself a bit more sane. I will demonstrate simple and straightforward way to accomplish this task.
Today, I will describe how to cause PostgreSQL clusters to reload their configuration files using four simple methods.
The GNU Privacy Guard is an essential application when you need to ensure the confidentiality and origin of the information, so it helps to protect your privacy and the people you communicate with.
The more hard drives are lying around and the more you use them, then it becomes more important to know how to unambiguously determine file system type without mounting it.
Sometimes, I want to prevent regular users from logging into the system to perform more complex operations. To achieve that, I am using Pluggable Authentication Modules for Linux to temporarily disable user logins.
This is a follow up to the previous article. I will briefly describe a way to boot Debian installation ISO image from USB flash drive using syslinux bootloader.
Today, I will show you how to create customized USB flash drive to boot selected ISO images using Syslinux bootloader for Linux ext4 filesystem. It is very handy and useful, so let’s begin immediately.
I unconsciously keep my thumbs on built-in touchpad, so I decided to use external mouse and automatically disable touchpad for the time mouse is connected.
It is a short entry, but a useful one, as it is important to have a basic knowledge of how to schedule system reboot or power it down automatically at specified time.
I constantly forget to add myself to the proper user group to access USB devices from within VirtualBox virtual machines, so I need to write it down.
Some time ago, I have recovered an old hard drive only to learn that it contained encrypted LVM logical volume.
Currently, I am playing with recent Ubuntu Wily Werewolf on my personal notebook. The first thing I did after system installation was to configure CPU governor and set it at system boot.
While this is not my primary area of expertise, I have been using John the Ripper more frequently lately, so I began to wonder how to take advantage of the powerful Nvidia GPU…
Recently described hddtemp application does not contain every possible hard drive in its database. I’ll be honest here, its development stopped many years ago, but it is still very useful, so I will shortly describe how to add new hard drive to the database.
It is often overlooked that hard drives which are available on the market provide temperature measurements. This temperature can be effortlessly monitored using hddtemp application by Emmanuel Varagnat.
I have successfully used Google Drive and Insync to organize all of the e-books that I have acquired during the last years. Currently I plan to upload them to a personal DokuWiki instance since I use it more every day. Before I can start, I need to extract cover images to ensure that I will get a decent outcome.
Today, I will explain how to automatically choose nearest mirror based on geographic and network location using Debian mirrors HTTP redirector to solve the common problem of choosing an appropriate mirror.
I had an unexpected incident last week as one of the hard disks in my server failed. This device was a part of a software RAID mirror, which created an opportunity to describe the whole process.
Maybe it is rarely needed, but recently, I found it very useful to know how to record an interactive session, so I could reference to it later or just examine it further.
It is easy to lock the screen when using any of the available desktop environments or even basic X Window utilities. The more interesting thing is to achieve the same functionality on a text-only based system.
A week ago I wrote about a couple of interesting applications that can crack passwords, but they were not as fast as I thought. After investigating this topic further, I ended up using a community-enhanced version of John the Ripper.
I have recovered old backup only to learn that I do not remember password to the found archive. As a result, I checked out two command-line applications to crack passwords used to encrypt zip, 7z or rar archives.
I have created a simple shell script to convert manual pages to DokuWiki as I want to have them always at hand and easily interlink to them from other pages.
Today I want to mention a simple and neat trick described in the kill manual page, which will allow you to quickly kill every eligible process.
Several months ago I have shortly described how to close a non-responsive ssh session, which comes in handy at times. Today I will describe how to close every active ssh session by inspecting existing pseudoterminals.
It is easy to use the uptime command, but a custom shell script is definitely a more interesting solution as it provides more detailed information.
I have unexpectedly experienced an issue with a couple of broken packages, which was easily solved using debsums utility.
Today I would like to tell you how to search for files by date, which is a very useful skill when you spend most of your time on the command-line.
I want to automatically log out the user from the login shell after a defined period of inactivity but leave X Window Terminals untouched. This will allow me to enhance security slightly, as I will not accidentally leave the superuser session running for a long time.
When managing large datasets, it is remarkably easy to end up with orphaned files, those without an assigned owner or group. These files can persist unseen, potentially creating security vulnerabilities or just contributing to system clutter. Fortunately, the find utility provides a direct method to locate them.
I often want to save a recently executed command to the personal log file for further reference, so let’s do it.
On Sunday 29th April 2012, I have described How to check dd’s progress using User-defined signal 1. Today, I will extend this topic further using the proc filesystem.
Using find command is not always the fastest way to search for specific files. The better method is to use mlocate utility, which uses its own file database and provides only user-accessible results.
Simple shell script that will iterate through the directories in the PATH variable and print only files identified as scripts.
I am constantly on the move, so sometimes I need to quickly verify my external IP address, as I do not want to accidentally block myself on some kind of firewall.
Yesterday, I left a long-running copy process between two external USB hard-drives. I did not want to assume anything, so I created a simple shell script to ensure that the whole process went smoothly.
I have already written a blog post about useful Bourne Again SHell key sequences, so today, I will touch on another important aspect of the daily routine – the history.
The default interactive shell in Debian is Bourne Again SHell, so it is worth to invest some time to at least skim through the available readline key sequences to gain higher proficiency at the command-line.
Not well documented, but a quick and simple operation.
It is a very simple operation that can be effectively used inside shell scripts.
This weekend I encountered a simple, but interesting topic, which concerns comparing the contents of two directories. The fun part is that you don’t need any additional utilities as standard diff command is fully sufficient.
During my recent activity I have noted to check out how to extract an ISO image in a traditional way using only shell utilities. It turned out to be easier than I thought, so I will present you three different solutions.
Today I have found an interesting issue as I tried to forbid shell script execution from different directory.
Currently, I am working over an unstable network connection, so my SSH session is constantly disconnected. It is a very uncomfortable situation as a dropped SSH connection freezes the whole terminal.
Today I needed to archive every non-hidden directory in several different locations. I do not like to repeat myself so after a while I quickly created a shell script to accomplish this task.
If you are wondering how to count only local users ignoring system accounts, I will give you a concise and straight answer.
Today I will shortly describe how you can remotely check the PostgreSQL version and use it inside shell scripts. This ability comes in handy at times, as it can be used to perform different tasks depending on the returned database version.
There are two ways to non-interactively provide a password for the psql command (PostgreSQL interactive terminal). Each method allows you to quickly write shell scripts using terminal-based PostgreSQL utilities as you can provide user credentials from the password file or environment variables.
Seven days ago I have published a shell script to highlight text in the terminal using sed or ssed. Today I want to extend the idea and colorize specified strings or simple regular expressions using just bash, getopts and ssed respectively.
I have been working on a simple shell script to highlight text in the terminal for the last hour. At first, I looked at it from the wrong angle, but after a short break, I finally realized the simplest possible solution.
The easiest way to reliably use Serial port within the local network is to use RS-232/422/485 NPort Device Server produced by Moxa company. I will shortly describe how to install NPort 5110 (1-port RS-232 serial device server) on Debian Wheezy.
I am using Jekyll to generate this website for half a year and Gandi for an even longer period of time so at the beginning of this year I revisited How to quickly download or upload directory tree over FTP post and created a simple but useful shell script to automate build and upload process.
You have probably already noticed my favorite way to overcome the sudo redirection issue, but if you haven’t, then I will write it down here for further reference.
By default, the dmesg command prints the kernel ring buffer with a timestamp for each logged message. It is easy to change this behavior and display date/time in a human-readable form using just one additional parameter. Still, sometimes it is not supported, so I will shortly touch upon this topic.
It is very easy to tell how long the system has been running using uptime command, but the information when exactly it was booted is not so apparent, so I will show you two different ways to get it.
Whenever I see an auto-login feature implemented by using an X login manager, I immediately think about how to automatically login a user at the console without even touching the graphical user interface.
It is good to know how to tell which package a specified file belongs to as this knowledge could be very useful during a system upgrade or unexpected system failure.
Sometimes I need to explicitly indicate the execution of a specified shell script or just an action taken inside it. My favorite way is to use advanced pc-speaker beeper, which is directly available in Debian repository.
A couple of days ago, I was asked how to check the last mount time of the ext2/ext3/ext4 filesystem. The solution is straightforward as it does not require anything more than the tune2fs utility.
It is straightforward to display available updates using an application with a graphical user interface, but not so obvious to do it by using shell commands only. I will shed some useful light on the subject so we could both benefit from it.
At the beginning of the last year, I wrote about VirtualBox image conversion. Today, I will continue this topic further and describe how to control the virtual machine using the command line.
I was always curious about how to list local displays as it is a quite interesting issue. Solution is not immediately apparent, but easy enough to spot after a while as it does not require anything more than little observations.
There are at least a couple of ways to hold a specific package and prevent it from being updated as you can use apt, dpkg, aptitude, dselect, or apt preferences, but only the last one is effective in every case.
I was wondering how to calculate Julian Day Number as I will need it to determine the sunrise and sunset times. Algorithms are extensively described so I will just point you to the two most useful pages – Julian day/Wikipedia and Julian Day Numbers/UT.
After writing the previous blog entry, I started to think about how to specify page section when opening the manual page. It is a simple but quite interesting issue, so I quickly got curious and wrote this post to describe a straight solution. Just to be clear – I need to mention that I am not writing about section numbers describing distinct subject areas but just page sections, such as NAME, SYNOPSIS, DESCRIPTION, AUTHORS, and so on.
Last year I wrote a short article about how to set up SSH port forwarding but I forgot to mention that you can quickly terminate existing port forwardings and create new ones during the SSH connection.
Recently I discovered console based task manager – devtodo. It is a very useful tool as you can easily use it over an SSH connection, create multiple different lists and combine them together. I will shortly describe devtodo utility available in Debian package repository but you need to know that you can use newer version – devtodo 2.
I was wondering how to read the total CPU usage of a group of processes. Then I came up with a straightforward solution using top and awk commands.
It is a very easy task as it requires only the use of the ncal command.
Today I was writing a shell script that performs different actions depending on the day of the month. Nothing fancy but then I came across an interesting issue, which is how to get number of days in a month. I got interested and started playing with shell commands, namely cal and awk utilities.
Re-read partition table without machine reboot using partprobe utility which is a part of parted package.
A couple of days ago, I described a couple of interesting ways to interact with KDE using the D-Bus message bus. Today I will show how to set up a semi-intelligent screensaver to just wait during YouTube video playback.
Today I was playing with the D-Bus message bus and KDE so I will describe here a couple of basic actions that can be quickly automated by using shell commands. It shouldn’t matter much but I need to mention that I am using KDE 4.9.5.
Around three weeks ago I wrote an article on how to automate mouse and keyboard. It was a very fun experience but as the former article was quite long I didn’t mention the wmctrl tool. It is an excellent complement to the previously described tools.
I came across ACPI wakeup wiki article while writing previous post, got interested and checked how to automatically wake up notebook. It is really simple as you can quickly set wake up time using date command, just remember to use Unix time.
Recently I was wondering if it would be possible to automate mouse and keyboard actions. The answer is obviously yes as you can use xautomation and xdotool tools. I will describe them in a couple of simple examples.
Change the MAC address of an Ethernet interface and make this change permanent. I will briefly explain how to do this using standard commands and one particularly useful tool MAC Changer.
Recently I was wondering how to automatically set up an external monitor without using desktop utilities as I don’t like to configure it each time. This question provided me a lot of fun as it opens a couple of interesting possibilities.
Recently battery in my notebook started to behave erratically. It will charge only to 70-80% of its maximum capacity. I suspect that it is probably slowly dying, so I will have to replace it soon, but at first, I will look at several utilities to monitor battery capacity.
It is very annoying to hear loud beeps at home especially at night or when listening to music. To turn off the system bell just follow a couple of steps below and enjoy pure silence.
Yesterday, I wrote a short note about VLAN interfaces. Today, I want to write a short entry on how to bridge Ethernet interfaces to keep things complete as I need to mention creating an ACCESS port to tag packets on desired interface.
Simple shell script to backup MySQL databases.
I am playing with DHCP option 82 so I need to read DHCP packets. The easiest way to do this is to use dhcpdump by Edwin Groothuis because of very simple usage and friendly output.
This is a rarely performed task but an easy one. To change time zone you need to reconfigure tzdata package.
The easiest way to remove comments from a shell script is to use sed (stream editor for filtering and transforming text) command.
Recently I needed to replicate data between two Linux servers so I could mitigate potential hardware failure. To achieve this goal I used GlusterFS – an Open Source distributed file system. In this example I will use Debian Wheezy as I want to try more recent version of GlusterFS.
When you’re not sure when daylight saving time changes you can quickly check it using the zdump command which is available on every *nix system.
Ubuntu Precise 12.04 currently contains in repository youtube-dl version 2012.02.27-1. Due to recent YouTube changes, this package version is no longer usable but there is an updated version in the Ubuntu Quantal 12.10 repository. To use it you need to perform a couple of steps described below.
Quick Response Codes are appearing everywhere. You can see them in museums, near the tourist attractions or all over the web. There is no doubt that QR Codes are useful as they can contain any information within reasonable limits.
SSH port forwarding is a nice feature that allows you to create encrypted tunnels over an unsecured network. It is easy and straightforward to remember and use in daily work so I will describe it here with couple of examples.
For some reason unknown to me there is no reboot option in web-based user interface but it doesn’t mean that it cannot be done easily as you just need to use one specific URL parameter.
Simple solution using Linux Unified Key Setup.
DOS partition table We can use sfdisk to dump partition table in usable format and store it: $ sudo sfdisk -d /dev/sda > sda_partitions Partition table can be restored using stored backup: $ sudo sfdisk /dev/sda < sda_partitions Partition table can be easily cloned (from sda to sdz in this example): $ sudo sfdisk -d /dev/sda | sfdisk /dev/sdz GPT To backup GUID partition table use sgdisk command (from gdisk package): $ sudo sgdisk -b sda_gpt_backup /dev/sda Restore it in similar way:
I recently needed to know the UUID (universally unique identifier) of my bootable USB root partition. It is a better way to distinguish storage devices because device names can change depending on the connection order.
Just a moment ago I connected my old hard drive and realized that it was a RAID member.
This post contains notes on this topic in the form of a concise guide.
Check the progress of the dd process.
The fastest way to download or upload directory tree over FTP using just plain console is to execute lftp command.
Download mb2md.pl script and run as described in the manual. For example to convert /old/mbox to /new/maildir you can execute: # perl ./mb2md.pl -s /old/mbox -d /new/maildir Converting /old/mbox to maildir: /new/maildir Source Mbox is /old/mbox Target Maildir is /new/maildir Dummy mail system first message detected and not saved. 40 messages.
This post describes a quick way to create .htaccess rewrite rules after permalinks change from /%post_id% to /%year%/%monthnum%/%day%/%postname%/
Sometimes it is a good idea to check or just store contents of the virtual console terminal (/dev/vcs[1-63] device).
Display established TCP connections inside the terminal.
For this example I will use such a tree: . ├── dir1/ │ ├── dir6/ │ ├── dir7/ │ ├── dir8/ │ ├── file4 │ └── file5 ├── dir2/ │ └── dir9/ │ ├── dir10/ │ │ ├── file9 │ │ └── file10 │ ├── file6 │ ├── file7 │ └── file8 ├── dir3/ ├── dir4/ ├── dir5/ ├── file1 ├── file2 └── file3 List of all files and directories: $ find . | sort | grep -v ^.$ ./dir1 ./dir1/dir6 ./dir1/dir7 ./dir1/dir8 ./dir1/file4 ./dir1/file5 ./dir2 ./dir2/dir9 ./dir2/dir9/dir10 ./dir2/dir9/dir10/file9 ./dir2/dir9/dir10/file10 ./dir2/dir9/file6 ./dir2/dir9/file7 ./dir2/dir9/file8 ./dir3 ./dir4 ./dir5 ./file1 ./file2 ./file3 Number of all files and directories:
My ISP provides a dynamically assigned IP address using DHCP. This solution has a couple of drawbacks but it comes in handy if I need to change the IP address to overcome time limit restrictions on streaming services…
If you downloaded deb package and wonder how to install it then just look at the snippet posted below.
This simple script will create web thumbnail using cutycapt console command.
There are a couple of different ways to perform this task using shell date command depending on the OS used. I will concentrate on Ubuntu Linux, OpenBSD and FreeBSD.
Execute a set of commands inside each active jail.
Create shell script to create image based jail in FreeBSD 7.
Use sort utility to sort IP addresses.
Let’s say that we have one big file and want to split it into 10M parts.
Managing SPS switches could be real fun if you use expect to automate such tasks.
Sometimes I need to downscale video for a portable device.
Get rid of spaces in file/directory names.
Perform HTTP compression test using curl utility.
Using KDE notification area within a shell script gives a lot of useful possibilities as you can easily display feedback from running services, other scripts, log analyzers.