Sandra Henry-Stocker

Author Archives: Sandra Henry-Stocker

Monitoring failed login attempts on Linux

Repeated failed login attempts on a Linux server can indicate that someone is trying to break into an account or might only mean that someone forgot their password or is mistyping it. In this post, we look at how you can check for failed login attempts and check your system's settings to see when accounts will be locked to deal with the problem.One of the first things you need to know is how to check if logins are failing. The command below looks for indications of failed logins in the /var/log/auth.log file used on Ubuntu and related systems. When someone tries logging in with a wrong or misspelled password, failed logins will show up as in the lines below:To read this article in full, please click here

How to sort ps output

The ps command is key to understanding what's running on your Linux system and the resources that each process is using. It's useful to know how to display the information that ps provides in whatever way helps you focus on the problem you're trying to resolve. One aspect of this is being able to sort the output of the ps aux command by any column to highlight particular information, such as how much memory processes are using or how long they've been running.The trick involves using the ps command's --sort option and knowing how to specify the column that you want to use for the sort. By default, ps sorts by process IDs (PIDs), showing the smallest first. PID 1 will appear at the top of the list, right under the column headings. The rest will follow in numeric order.To read this article in full, please click here

Tagging commands on Linux

Tags provide an easy way to associate strings that look like hash tags (e.g., #HOME) with commands that you run on the command line. Once a tag is established, you can rerun the associated command without having to retype it. Instead, you simply type the tag. The idea is to use tags that are easy to remember for commands that are complex or bothersome to retype.Unlike setting up an alias, tags are associated with your command history. For this reason, they only remain available if you keep using them. Once you stop using a tag, it will slowly disappear from your command history file. Of course, for most of us, that means we can type 500 or 1,000 commands before this happens. So, tags are a good way to rerun commands that are going to be useful for some period of time, but not for those that you want to have available permanently.To read this article in full, please click here

Using the Midnight Commander to browse Linux directories

Midnight Commander – the "mc" command – provides an easy way to browse directories and to view, move, delete, compare, change and edit files. Similar in some ways to ranger, mc makes it easy to move around directories and offers side-by-side file/directory listings that work independently of each other. In addition, it provides a very wide range of actions that you can take through simple menu choices.To start Midnight Commander, simply type "mc" in a terminal window. When you open mc, both the left and right sides of the display will look the same and will show the contents of whatever directory you started in. You can switch sides using the tab key or simply by clicking on a directory or file in the side of the display. You can select a file or directory simply by clicking on it. You can also browse directory contents using the up and down arrow keys.To read this article in full, please click here

How to modify user-account settings with usermod

There are quite a few changes you can make to user accounts on Linux systems: setting them up, deleting or disabling them, adding or removing users from secondary groups, changing usernames or UIDs, moving home directories, changing users’ shells, altering account expiration timing, and so on.One command that can make nearly all of these changes easier is usermod. The only real constraints are 1) that the accounts you intend to change must already exist on the system (this command won’t set them up from scratch), and 2) that the affected users should probably not be logged in when you make these changes.The basic syntax for the command is usermod [options] LOGIN but that options section has a lot more possibilities than you might anticipate. In addition, sudo permissions will be required for this command since superuser access is required to set up or change nearly all user account settings.To read this article in full, please click here

How to modifying user-account settings with usermod

There are quite a few changes you can make to user accounts on Linux systems: setting them up, deleting or disabling them, adding or removing users from secondary groups, changing usernames or UIDs, moving home directories, changing users’ shells, altering account expiration timing, and so on.One command that can make nearly all of these changes easier is usermod. The only real constraints are 1) that the accounts you intend to change must already exist on the system (this command won’t set them up from scratch), and 2) that the affected users should probably not be logged in when you make these changes.The basic syntax for the command is usermod [options] LOGIN but that options section has a lot more possibilities than you might anticipate. In addition, sudo permissions will be required for this command since superuser access is required to set up or change nearly all user account settings.To read this article in full, please click here

Disowning a process in Linux

When you want a process to continue running even after you log off a Linux system, you have a couple options.One of them is to use the disown command. It tells your shell to refrain from sending a HUP (hangup) signal to the process when you log off. So, the process continues running. This can be very handy whenever you start a process and then, for some reason, you can’t stay logged in and wait until it finishes.[Get regularly scheduled insights by signing up for Network World newsletters.] The disown command is a shell built-in. This means that you don’t have to install it to use it, but it also means that it won’t be available if you use a shell that doesn’t support it. For those of us using bash and related shells (zsh, ksh etc.), disown should be available and you can verify this with a command like this that lists shell built-ins and then looks for "disown":To read this article in full, please click here

How to enforce password complexity on Linux

Deploying password-quality checking on your Debian-based Linux servers can help ensure that your users assign reasonably secure passwords to their accounts, but the settings themselves can be a bit misleading.For example, setting a minimum password length of 12 characters does not necessarily mean that all your users' passwords will actually have 12 or more characters.Let's stroll down Complexity Boulevard and see how the settings work and examine some that are worth considering.[Get regularly scheduled insights by signing up for Network World newsletters.] The files that contain the settings we're going to look at will be:To read this article in full, please click here

How to enforce password complexity on Linux

Deploying password-quality checking on your Debian-based Linux servers can help ensure that your users assign reasonably secure passwords to their accounts, but the settings themselves can be a bit misleading.For example, setting a minimum password length of 12 characters does not necessarily mean that all your users' passwords will actually have 12 or more characters.Let's stroll down Complexity Boulevard and see how the settings work and examine some that are worth considering.[Get regularly scheduled insights by signing up for Network World newsletters.] The files that contain the settings we're going to look at will be:To read this article in full, please click here

How to download and play YouTube and other videos on Linux

Who would have imagined that there’s a Linux tool available for downloading YouTube videos? Well, there is and it works for Linux as well as for other operating systems. So, if you need to watch some of the available videos even when your internet connection is flaky or you need to be offline for a while, this tool can be especially handy.The tool for downloading videos is called youtube-dl. (The “dl” portion undoubtedly means “download”.) It’s very easy to use and drops webm or mp4 files onto your system. Both formats provide compressed, high-quality video files that you can watch whenever you like.To read this article in full, please click here

Navigating your Linux files with ranger

Ranger is a unique and very handy file system navigator that allows you to move around in your Linux file system, go in and out of subdirectories, view text-file contents and even make changes to files without leaving the tool.It runs in a terminal window and lets you navigate by pressing arrow keys. It provides a multi-level file display that makes it easy to see where you are, move around the file system and select particular files.To install ranger, use your standard install command (e.g., sudo apt install ranger). To start it, simply type “ranger”. It comes with a lengthy, very detailed man page, but getting started with ranger is very simple.To read this article in full, please click here

Recovering deleted files on Linux with testdisk

When you delete a file on a Linux system, it isn’t necessarily gone forever, especially if you just recently deleted it.Unless you rubbed it out with a tool such as shred, the data will still be sitting on your disk—and one of the best tools for recovering deleted files, testdisk, can help you rescue it. While testdisk has a wide range of functionality including recovering lost or damaged partitions and making non-booting disks bootable again, it’s also frequently used to restore files that were deleted by mistake.In this post, we’ll take a look at how you can recover deleted files using testdisk and what each step in the process looks like. Since the process requires quite a few steps, you’re likely to feel more comfortable running through them once you’ve done it a few times.To read this article in full, please click here

How to view information on your Linux devices with lshw

While far from being one of the first 50 Linux commands anyone learns, the lshw command (read as “ls hardware”) can provide a lot of useful details on your system’s hardware.It extracts details—maybe quite a few more than you knew were available—in a format that is reasonably easy to digest. Given descriptions, logical (device) names, sizes, etc., you are likely to appreciate how much detail you can access.This post examines the information that lshw provides with a particular focus on disk and related hardware. Here is some sample lshw output:$ sudo lshw -C disk *-disk:0 description: SCSI Disk product: Card Reader-1 vendor: JIE LI physical id: 0.0.0 bus info: [email protected]:0.0.0 logical name: /dev/sdc version: 1.00 capabilities: removable configuration: logicalsectorsize=512 sectorsize=512 *-medium physical id: 0 logical name: /dev/sdc Note that you should run the lshw command with sudo to ensure that you get all of the available details.To read this article in full, please click here

Using bash’s shopt builtin to manage Linux shell behavior

If you haven’t tried it yet, you might be surprised by the many features of shopt. While it works like a Linux command, it’s actually a bash shell builtin that allows you to change many things about that shell’s behavior.One option, for example, allows the shell to fix minor typos when you type directory names. To demonstrate, in the first cd command shown below, the directory name, bin, is typed with an extra letter and the shell complains and gives up:$ cd binn -bash: cd: binn: No such file or directory This next command enables the cdspell option that gets bash to attempt to correct minor typos in directory names.To read this article in full, please click here

Using the Linux stat command to create flexible file listings

The stat command supplies a lot of detailed information on files.It provides not just the date/time of the most recent file changes, but also shows when files were most recently accessed and permissions changed. It tells you the file size in both bytes and blocks. It displays the inode being used by the file along with the file type. It includes the file owner and the associated user group both by name and UID/GID. It displays file permissions in both the “rwx” (referred to as the “human-readable” format) and numerically. On some systems, it might even include the date and time that a file was created (called its “birth”).[Get regularly scheduled insights by signing up for Network World newsletters.] In addition to providing all this information, the stat command can also be used to create file listings. These listings are extremely flexible in that you can choose to include any or all of the information described above.To read this article in full, please click here

Enhancing the Linux command line with aliases

Want to get work done a little faster, spend less time remembering commands and maybe even show your coworkers how clever you are? Easy. Set up several dozen bash aliases.Your days will get easier and a tad less stressful. You might even have some fun. In this post, we'll look at the various types of aliases that you can set up, and what you need to know to manage them.[Get regularly scheduled insights by signing up for Network World newsletters.] Why use aliases? Using aliases helps you to avoid having to type a lot of command details, especially those that are hard to remember or require a lengthy string of options that might have to be entered in some particular order before they'll spit out just the output that you're waiting to see.To read this article in full, please click here

11 ways to list and sort files on Linux

There are many ways to list files and display information about them on Linux systems. This post reviews a number of commands that provide details on files and provides options for customizing your file listings to meet your needs.Most of the commands list files within individual directories while others reach as deeply into a file system as you care to look.The primary command for listing files is, of course, ls. This command, however, has an extensive number of options for finding and listing just the files you want to see. Plus, there's always find for helping with very specific file searches.Listing files by name The easiest way to list files by name is simply to list them using the ls command. Listing files by name (alphanumeric order) is, after all, the default. You can choose the ls (no details) or ls -l (lots of details) to determine your view.To read this article in full, please click here

Managing process accounting on Linux

Process accounting is a method of recording and summarizing commands and processes. It's an option on Linux systems, but you have to enable it and use a particular command to view the details collected. This post covers the commands involved and offers some suggestions on making the views even more useful.To start, understand that process accounting is different than what you see when running the ps command. It shows details on commands that have completed –- not those that are currently running. It also shows a lot more details than you would see by looking at your users' command history files and keeps all the collected data in a single file on the system.To read this article in full, please click here

Word game: Finding anadromes with Linux

In these stressful times, one way to distract ourselves from the gloom is by playing word games. With this thought in mind, I challenged myself to identify words that, spelled backwards, would still be words.Instead of cheating by doing a simple Google search, I cheated by using my Linux commands skills. So, in this post, we’ll look at how Linux commands and resources can be used to identify such words.Defining the search Before we get started on the Linux search technique, I should point out that what I was looking for were not just palindromes – words like “civic” and “deified” that read the same from left to right as they do right to left. Instead, I was also looking for words like “reward” and “decaf” that turn into different words – in this case, “drawer” and “faced” -- when one reads them backwards.To read this article in full, please click here

Merging and sorting files on Linux

There are a number of ways to merge and sort text files on Linux, but how to go about it depends on what you're trying to accomplish – whether you simply want to put the content of multiple files into one big file, or organize it in some way that makes it easier to use. In this post, we'll look at some commands for sorting and merging file contents and focus on how the results differ.Using cat If all you want to do is pull a group of files together into a single file, the cat command is an easy choice. All you have to do is type "cat" and then list the files on the command line in the order in which you want them included in the merged file. Redirect the output of the command to the file you want to create. If a file with the specified name already exists, it will be overwritten by the one you are creating. For example:To read this article in full, please click here

1 2 3 14