The PATH to /home/timmy/grannys_house (Revisited)

Back in the old days, when Timmy wanted to visit granny’s house, all he had to do was have Lassie lead him there. In today’s more complicated computer world, it takes a bit more understanding.

We’re going to learn a bit about a very important subject in Linux. It’s called PATH. The path to a file or whatever on your Linux operating system is something that you need to understand when manipulating files from the command line. Another term we’ll look at briefly is the working directory.

When Timmy, as a regular user, opens his terminal from his GUI or from the post login command line (Run Level 3 – multi-user, no X running), his working directory is in /home/timmy. Whichever directory you are in at the time is known as the working directory. Timmy may navigate to another directory using the cd command. Let’s say he navigates to /usr/bin. At that time, his working directory becomes /usr/bin. See how this works?

Think of the Linux file system as a multi-room house. If you’re in bedroom4 right now, your working directory would be /house/bedroom4. If you walked out of that room and down the hall to bathroom02, then your working directory becomes /house/bathroom02. At that time, you may then use the command micturate. Heh! A little bathroom humor there.

OK, so now we know all about the working directory, right? Moving on…

Let’s say that Timmy wants to copy a .jpg that is in /usr/share/wallpaper over to the /home/timmy/grannys_house directory. He would open his terminal, which would then be sitting there with that blinking cursor waiting for Timmy’s next command:

timmy@lassies_machine~:$ |

Timmy’s working directory at this point is /home/timmy, as designated by the command line shorthand character ~ . If Timmy wants to copy the .jpg without actually going to the directory that it’s in to copy it, he must provide the proper path in his command.

timmy@lassies_machine~:$ cp /usr/share/wallpaper/cabin.jpg /home/timmy/grannys_house

The above command, using absolute path names, directs the shell (command line interpreter) to copy the cabin.jpg image from the /usr/share/wallpaper directory to the /home/timmy/grannys_house directory. If Timmy wanted to just make a duplicate of a file in his /home/timmy directory, then he could leave off the / character when showing the command line the proper path. This can be done because he’s already in the /home/timmy directory. It is his working directory. He can now use a relative path to direct the shell to make the copy.

timmy@lassies_machine~:$ cp cabin.jpg cabin.jpg_backup

In the above example, notice that there is no / being used. Timmy is simply making a backup copy of cabin.jpg. Both files are relative to his working directory, so the shell understands that Timmy just wants to make this duplicate right there in that same directory.

It’s really not rocket science, to use that worn out old cliché. The command line can be pretty simple once you get the hang of it folks. You know what I always say… Don’t fear the command line. I hope you’ve learned something here today. Remember to click the links within the article. You’ll find some more useful information and a few definitions for you there.

Later…

~Eric

Further reading:

Unix Commands @ Wikipedia

LinuxTutorial.info

Linfo.org

Paul Sheer’s Rute Users Tutorial and Exposition

Image credits: Timmy (Jon Provost) and Lassie image owned and copyright by Classic Media

Note: This article originally appeared on my old Nocturnal Slacker/Lockergnome Blog (now defunct).


Linux – How I Got Here… and Where I’m Headed

Sometimes, we all have to look back down the path we’ve taken to more fully understand that path that lies ahead.

I started my Linux Adventure a bit late in life. I’ve always had an interest in all things technical. My career for the majority of my working life was as an electronics technician (component level repair). I had aspirations at one time of gaining an engineering degree in electronics; other paths were taken, though.

My first experience with computers and programming and such was in 1979-80, when I was attending tech school. We were trained on kit-made 8080A computers that were so primitive that they were programmed directly via octal machine code. The outputs of the machines were led light displays. This was ridiculously simplistic by today’s computing standards.

I didn’t choose computers as my field of endeavor, though. I was much more interested in RF (radio frequency) and audio electronics. That decision probably made for a much different life than others would have. I regret lacking the vision that others had regarding the future of the computer. Hindsight shows me that I would have enjoyed a career in that field very much.

I did not have much interaction with computers from the early 80s till about 2000, with the exception of some fun times with a Commodore SX64 and some intriguing games from a company called Infocom. Oh, I had some experience with PC-type systems at the workplace in the early 90s, but I never really developed a passion for them.

I remember in the late 90s sitting at my kitchen table reading computer store ads and dreaming about getting a system for my home. I never could justify the money for it, unfortunately. I had other priorities. In 2000, my brother bought a new system for himself and passed his old system on to me. It was a little Pentium I – 90Mhz machine. I set that guy up and signed on to a bunch of free dial-up ISPs and off I went…

My current passion with computers and operating systems came about directly from my initial experiences with the Internet in 2000. Yeah, I was a little late coming to the party. I’ve been trying to catch up ever since. I have come a long way, though. I’ve been building my own systems since 2001 or so. I crossed over from MS Windows to GNU/Linux in 2006. I’m currently reading and learning all I can about the GNU/Linux operating system.

I made some resolutions in the new year to learn more about specific Linux subjects; one in particular was shell scripting. I’m currently reading and experimenting with that now. I’m also publishing some basic lessons regarding this stuff as I go along. I learned a long time ago that a great method for learning is to learn by teaching. I have to research and learn something before I can write an article about it here.

Whatever I learn, I like to pass on to others. That is the beating heart of the GNU/Linux Open Source community. I have learned so much from the selfless acts of others in this community that I am driven to give something back. It is a mission of mine to educate, to assist, to entertain, and to ease the transition of new Linux Adventurers into this wonderful community. I am no guru when it comes to Linux, but I have gained enough knowledge to get around without getting lost too often. I have much to learn yet, but when I do learn it, I’ll be here or somewhere helping others to learn it too.

A man called Bruno inspired me.

I would one day love to earn a living writing technical related articles or books regarding GNU/Linux. I would like to be employed in some fashion that would allow me to use my knowledge in a GNU/Linux business environment; as a systems administrator or a technical writer for some company or other. Sadly, my late-coming to the party and the fact that I’m no young spring chicken anymore has hindered my abilities to secure any positions like these. I’m totally self-taught and hold no industry certifications. I would love to attend school again to learn more in this field, but again… it doesn’t always work out that way.

I’m not at all sure what my future path is going to be like. It’s a day-to-day thing right now. However, I will always be learning; and with any luck, I’ll always be here passing it along to you.

Thanks for reading/commenting.

Later…

~Eric