How To: Go To A Specific Line In Nano

In today’s article, we’re going to learn how you can go to a specific line in Nano. It’ll be an easy article, perhaps even a fairly brief article. There are a just a couple of ways to cover, so it won’t take all that much time or space.

Often, when things like scripts throw an error, they’ll tell you on which line number the error happened. There are often hundreds or thousands of lines in complicated files and navigating to the correct line number is tedious, prone to error.

You can be pressing the down arrow for quite a while! So, why not note the line number where the error occurred and open the file at that specific line? It’s perfectly good sense! It’s such good sense that I figured I’d write an article about it.

You all know that I’m a Nano fan. You can read the ‘big’ Nano article here. If that’s not enough, this link is to a search for Nano across the entire site. There are nearly 30 articles that use Nano in them. I really am quite a fan.

Why am I a fan? Well, the first link will probably tell you that, but I like it because it’s simple. Nano’s starting to be fairly universal. It’s light and that’s why I like it – it’s only meant for quick text file edits.

Nano’s not really the right tool for writing a book, nor would I want to use it to write large scripts or for programming. For what it is, it’s great. If it’s not great, odds are good that you’re not using it as the tool it is. Sure, it’ll work for other things, but it excels at being what it is – a quick text editor in the terminal.

Go To A Specific Line In Nano:

Nano is a terminal-based tool. So, you obviously need to have an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open. Tada! (That’s mostly copy/paste from previous articles, but I do sometimes mix it up a little!)

With  your terminal open, let’s show you how to go to a specific line in Nano. It’s pretty easy, and we’re going to use a file most users will have. If you don’t have a ~/.bash_history file, you can use any plain text file you want.

I suppose we should first make sure that you have Nano installed. To check, you can just look for the version. That’s done with:

Your output should look something like:

checking the nano version
As you can see, Nano is happily installed and ready for use.

If Nano isn’t installed, and you’re using any mainstream distro, it’s certainly in your default repositories. You can install it like you would any other piece of software in the repositories. 

Now, there are two ways to open and go to a specific line in Nano. The first is probably the easiest. Using our ~/.bash_history as an example, the command looks like this:

Where you see the +25 flag, that’s the place where you specify the line number to start with when  you open Nano. You can use any number you want, provided there are that many lines in the file you’re intending to edit.

The next way is also easy. Using your keyboard, press CTRL + Shift + . Nano will then present you with the chance to enter in a specific line. It looks like a lot like this:

open a specific line in nano
See? Follow the arrow and that’s where it prompts you to enter a line number. ‘Snot hard at all!

So, now you have two ways to go to a specific line in Nano. I told you that it was going to be easy! Nano is awesome.

Closure:

There’s another article! It’s on one of my favorite subjects – Nano. Now you’ve learned how to go to a specific line in Nano, which is a pretty handy trick to have in your toolbox. It can save you all sorts of time, and not just time scrolling. It means you aren’t paying attention to the rest of the fluff and you can concentrate better, or so it seems to me. For what it is, Nano is my favorite plain text editor and it’s remarkably useful at times.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Compress A File With WinRAR

Today’s article is going to teach you how to compress a file with WinRAR. This isn’t exactly something you’re going to do often, unless you share files with Windows users. If you do share files with Windows users, this isn’t such a terrible idea. There are worse ideas, some of which are on this site.

Before you get to excited, there are countless ways to compress a file in Linux. The odds of  you technically needing WinRAR are about zero. Still, that doesn’t mean we can’t have fun and learn new things!

Right?

Right!

It’s great to learn new things, even if you’re never gonna use them. Until about 5 minutes ago, I can’t remember the last time I felt the urge to compress a file with WinRAR. I’ve previously written about WinRAR, actually. 

How To: Extract An .rar File

So, if you follow that link you’ll learn how to perform the other end of this operation! I’d like to pretend I planned it that way, but I did not. No, there’s no rhyme or reason to the publication schedule – except you get a new article every other day.

Compress A File With WinRAR:

Yup. You’re gonna need an open terminal for this one. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

First, you’re going to need rar. It’s probably in your default repositories. It’s there for Debian, Ubuntu, and Mint. So, it’s probably available for you. You can get the proprietary version of WinRAR here. (Or not… I don’t see a whole lot of folks wanting that, but it’s there if you do! Also, I think it’s just a trial version.) Or, install it from your repositories. With those operating systems, it’s just:

Now, it’s really easy to compress a file with WinRAR. The command is:

The ‘a’ flag is telling the command to archive the file/folder you named. If you wanted to compress a file (or even a directory) named foo, it’d look like this:

See? That’s all you really needed to know if you want to compress a file with WinRAR. It’s not exactly complicated, but it’s helpful to know how if you come across a situation where you actually need to know. Again, there’s a zillion ways to compress files in Linux, so you’re not going to need this one all that often unless you really need it. If you do use WinRAR with Linux often, please leave a comment explaining why.

Closure:

Yup. It’s another article! This one teaches you how to compress a file with WinRAR. In my defense, this is information that’s from my notes. I have a whole lot of notes, but this one stood out today and so you get this for your article. You’re welcome!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Change The Timezone

In today’s article, I’m going to show you how to change the timezone. This isn’t a task you’ll need to do often, but it’ll be nice to know how to do it when you do need to change the timezone.

Personally, I find myself mostly needing to change the timezone when I lease a VPS and want the system timezone to match my own timezone. All in all, the  computer doesn’t actually care what timezone it is in, so you can set it to your local timezone and not have any issues. Normally, I’d configure the timezone during the installation process.

I suppose this is probably only going to work in systems that make use of systemd. It makes use of timedatectl and I’m pretty sure that’s a systemd thing. If this was a good site, the author would actually go verify this. You get what you pay for! Still, you may need another tool if you don’t use systemd.

It’s also going to be a fairly easy article. If you want to change the timezone, it’s not all that difficult. There really isn’t a whole lot to it. So, without further ado, let’s get into the article…

Change The Timezone:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

I suppose you should first know what timezone you’re currently using. To learn that information, you can use this command:

Your output might look something like this:

timedatectl output
Your timedatectl output may look different, obviously. You might not be in my timezone!

Anyhow, to change it, the format of the command is:

I suppose you might not know your timezone options. You can generate a giant list of ’em with this command:

If you don’t know your timezone options, you can use ‘grep’ to narrow it down. For example, if you’re pretty sure you’re in America, your command might look a little like:

That’ll narrow it down. By the way, the  “America” in this case actually more like ‘the Americas’ and far more than just the United States – or even  more than North America. That information might come in handy for some of you.

Closure:

Whelp, there you have it… You have another article. This one will show you how to change the timezone, which might be something you need to know from time to time. It’s probably not something you need to remember, but now you can easily search for it.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Change Your Home Directory

In today’s article you’re going to learn that it’s possible to change your home directory. Why? Because Ol’ David is in a bit of a rush to get this out on time. I can’t miss my publication deadline! So far, there has been an article every other day. Gotta keep up the schedule.

Yesterday was an extremely frustrating day. People managed to waste my entire afternoon. The only consolation I got was that I drove home really quickly, in a very spirited manner. That was not enough consolation. So, I just drank a couple of delicious beers (Sierra Nevada Pale Ale) and went to sleep.

I expected to get up early and write the article. I did wake up early, but I fell back to sleep. My body wanted to catch up on some missed sleep and it did. Which means I’ve got like an hour to write this article.

(I don’t think there has ever been a more ‘bloggy’ post than this one! It’s horrible and I’ll hopefully never do it again.)

When I first planned this article, I planned on showing you how to change your home directory with a new user. It was going to be fairly long and needlessly complicated. So, instead, I’m just going to tell you how to do it. You can learn how to create a new user.

So then, let’s get onto the meat of this…

Change Your Home Directory:

There are all sorts of reasons why you might want to change your home directory. Maybe you don’t want people being able to easily spot it by traversing your directory tree? You might want to move it to a different partition that has more space? Who knows?

But, this isn’t something you want to do willy-nilly. See, a whole lot of things depend on your home directory and your home directory probably contains a lot of stuff. So, after you’ve changed your home directory you’re probably going to need to move a lot of stuff around. That’s why it’s best to do this with a new user. If you want to practice this, I’d say do it to a new user. There’s a link in the preamble to learn how to create a new user.

The command is remarkably simple. Just open up your terminal and run:

So, if I wanted to move my home to /foo/bar, the command would look like:

You don’t have to specify /home/kgiii – even though that’s the full directory path. The -d command knows that we’re generally talking about the home directory. If you’ve already moved your home directory, and it is outside of the /home directory, you’re probably gonna have to specify that. I don’t actually know, I’ve never tried that.

This isn’t something I’d undertake lightly. I’d really only recommend this on a new user OR if there are some very specific circumstances. You might do this if you’ve filled up your disk space, added a new disk, and want to move your home directory to the new disk so that you don’t have to muck about with changing partitions or anything. Even then, it’s a bad solution – but probably one of the best solutions you have available.

Closure:

Consider this an article that’s for a very special set of circumstances. It’s for when someone on a forum has run out of disk space and wants a way out without any changes to partitioning and doesn’t want to reinstall. This isn’t something you probably need to go playing around with, but you can. I ain’t stopping you. The potential to make a mess of this is pretty strong.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Make A Symbolic Link

In this article, we’re going to learn how to make a symbolic link. This will be a very easy article, and one you may get some use from. It’s not terribly hard to make a symbolic link, though I suppose the syntax may seem quirky as compared to many other commands. It’s not hard, trust me on this… Or not… You can pretend it’s hard and impress your friends and family!

Ah well…

So, what’s a symbolic link? Well, it’s a link to another file. A symbolic link is a file that contains nothing more than a link to another file. There’s a hard link as well, and that points to an inode. A symbolic link is a bit more versatile. You can make a symbolic link (again, a file) and move it around the system and it’ll still point at the original file. It’s useful if you want to do things like put shortcuts on your desktop.

This being Linux, everything is a file. A symbolic link is a file. It is a file that contains information about where another file is located. Some folks think this sort of stuff is complicated, perhaps too complicated for a new Linux user, but I think it’s easy – so long as it’s properly explained. Darned if I know how to explain it! I hope that worked for you. That’s really all it is. That’s it. It’s just a file that contains information about where another file is located. Everything is a file.

Like I said, this is going to be a short article. It really shouldn’t be all that difficult to show you how to …

Make A Symbolic Link:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Now, pick a file… One that most users will have will be your Bash history, located at ~/.bash_history unless you’ve really done some heavy modifications. Let’s use that file to make a symbolic link.

The format to do this is:

Obviously, the -s means ‘symbolic’ (feel free to check ‘man ln‘ for more information) and you name the existing file first and then the file you want to create. So, to do this with .bash_history, it’d look like:

Now, you can see it in action:

Tada! It will show the contents of your .bash_history if you did everything correct. Want to see something even more handy?

Now, look at  your desktop and open the file named ‘test’ – or just navigate there in your terminal and check it again with the cat command:

Congratulations! You’ve learned how to make a symbolic link! I told you that it wasn’t all that hard. As a concept, it’s even easier to understand. The syntax to do so isn’t even all that difficult. You’ve got this! I have faith!

Closure:

Yes, yes I did say this would be quick and easy. I think it was. It’s not terribly hard to make a symbolic link and it was a fun article to write. It’s fun to cover some of the basics. As the tagline says, “Getting you up to speed!” Search around or just browse, you might be amazed at the subjects covered!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.