How to Rename a Directory on Linux

Your Data Is Safe

Renaming directories is something we all need to do from time to time.

We might create a directory and misspell its name, and we want to put it right. Often, the purpose of a directory changes over time or through the life of a project, and you want to adjust the name to reflect its new use. Perhaps you’ve decompressed an archive file and it’s created a directory tree with the directory names in uppercase and you’d like them in lowercase. Whatever the reason. renaming a directory doesn’t do anything to the data held inside it. It changes the path to that data, but the files and directories inside your renamed directory aren’t touched.

Don’t rename system directories. Changing the path to system files and commands is going to have a detrimental effect on the running of your computer, to say the least. If you need to use sudo to rename a directory—unless you really know what you’re doing—the chances are you shouldn’t be renaming it.

[mai mult...]

How to Use Linux Signals in Bash Scripts

Signals are short, fast, one-way messages sent to processes such as scripts, programs, and daemons. They let the process know about something that has happened. The user may have hit Ctrl+C, or the application may have tried to write to memory it doesn’t have access to.

If the author of the process has anticipated that a certain signal might be sent to it, they can write a routine into the program or script to handle that signal. Such a routine is called a signal handler. It catches or traps the signal, and performs some action in response to it.

[mai mult...]

How to Check Your BIOS Version and Update it

Multiple Windows computer on a desk

You probably shouldn’t update your BIOS, but sometimes you need to. Here’s how to check what BIOS version your computer is using and flash that new BIOS version onto your motherboard as quickly and safely as possible. Be very careful when updating your motherboard’s BIOS! If your computer freezes, crashes, or loses power during the process, the BIOS or UEFI firmware may be corrupted.

[mai mult...]

How to Traverse a Directory Tree on Linux

Directories on Linux let you group files in distinct, separate collections. The downside is it becomes tedious moving from directory to directory to perform a repetitive task. Here’s how to automate that.

The first command you learn when you’re introduced to Linux is probably ls, but cd won’t be far behind it. Understanding directories and how to move around them, particularly nested subdirectories, is a fundamental part of understanding how Linux organizes itself, and how you can organize your own work into files, directories, and subdirectories.

Grasping the concept of a tree of directories—and how to move between them—is one of the many little milestones you pass as you familiarize yourself with the landscape of Linux. Using cd with a path takes you to that directory. Shortcuts like cd ~ or cd on its own take you back to your home directory, and cd .. moves you up one level in the directory tree. Simple.

However, there isn’t an equally simple means of running a command in all directories of a directory tree. There are different ways we can achieve that functionality, but there isn’t a standard Linux command dedicated to that purpose.

Some commands, such as ls, have command-line options that force them to operate recursively, meaning they start in one directory and methodically work through the entire directory tree below that directory. For ls, it’s the -R (recursive) option.

If you need to use a command that doesn’t support recursion, you have to provide the recursive functionality yourself.

[mai mult...]