Archive

Archive for July, 2017

Let your computer continue to boot even if it can’t mount something in fstab

July 23rd, 2017 No comments

I have a Drobo, basically a consumer grade NAS or network file share device, that I store the majority of my media and documents on. The files are accessed via an exposed Windows share folder and because Linux doesn’t always play the nicest with that I’ve taken to force mounting these shares on my machine via fstab. The usual approach is to add something like this to your /etc/fstab file:

//{IP address of server}/Media    /media/Drobo/Media    cifs    guest,uid=1000,iocharset=utf8    0    0

I won’t get into all of the gory details here (for that see this older post) but essentially this tells the computer to map the shared Media folder on my Drobo to a location on my computer under /media/Drobo/Media. The problem with this approach is that if the Drobo is offline or if there is a network problem then it will cause the boot process to pause with an error and prompt me if I want to continue without mounting it. While this is fine it isn’t always ideal. For instance what if I wanted to do something similar with my laptop but not have to go through the hassle of OKing the boot every time it failed to find the Drobo when I’m away from home? Well thankfully there are a few more switches we can add to the fstab line to do just that!

Here is what my new fstab line looks like:

//{IP address of server}/Media    /media/Drobo/Media    cifs    nofail,x-systemd.automount,x-systemd.requires=network-online.target,x-systemd.device-timeout=10,guest,uid=1000,iocharset=utf8    0    0

I’ve bolded the new portion but it should be fairly obvious what is happening here. Basically the nofail option says “I don’t care if you can’t mount it, don’t stop with an error just keep going” where the other options specify requirements to even try such as network connectivity as well as a timeout value so I don’t have to wait long for it to realize that it can’t find the Drobo. With these added options I can easily boot with or without the Drobo being there and I’m never prompted with an error message.

Now a few things to note:

  • Adding nofail to devices you do need to mount, such as your root drive, is probably a terrible idea.
  • If the computer boots up when the Drobo isn’t there but later I bring the computer back to the network where the Drobo lives, it won’t automatically find and mount it for me. So that’s something you’ll still need to remember to do manually (by running sudo mount -a or something like that).

 

Categories: Linux, Tyler B Tags: ,

Open Document Formats: A Successful Transition?

July 22nd, 2017 No comments
Some Background

Years ago I wrote about my interest in switching away from proprietary binary blob formats (primarily things like Microsoft .doc, .xls & .ppt formats) and instead move to their more open alternatives (OpenDocument .odt, .ods & .odp and Office Open XML .docx, .xlsx & .pptx). The genesis for this drive was an article by Vincent Cerf where he was talking about the problems around reading these proprietary formats in the future, when the original vendors are either out of business or no longer interested in supporting them. By using a well defined and open standard instead we can not only preserve our data but we’ll also have more options and software choices available to us as well.

Where Are We Now?

OpenDocument is at version 1.2 with a 1.3 currently in the draft stage. It is supported by many office applications (including Microsoft Office) and has been adopted as the standard by many governments and organizations. Here are just some examples: Belgium, Brazil, Croatia, Denmark, France, Germany, Hungary, India, Italy, Japan, Latvia, Malaysia, Netherlands, Poland, Portugal, Slovakia, South Africa, Sweden, United Kingdom, Norway, Russia, Serbia, South Korea, Switzerland, Turkey, Uruguay and Venezuela as well as NATO and the European Union.

Office Open XML is currently standardized under ISO/IEC 29500:2008 and is the default file format for the Microsoft Office suite. As such it likely enjoys a much larger market share being the de facto file type for individuals and corporations who are using Microsoft Office.

Both formats are now very mature and stable and offer good feature sets and interoperability. However there are still application specific issues that may impact users. For instance as of this writing both Microsoft Office and LibreOffice applications still do not always represent the same document in the same way leading to formatting inconsistencies.

So How Did My Transition To Open Document Formats Go?

Personally I can’t remember the last time I chose to use any of the binary blob formats. Sure you occasionally come across them online or get them e-mailed to you but by and large the world has moved on. The Microsoft backed Office Open XML formats seem to be much more prevalent but that’s to be expected as the default file format for the most popular office suite in the world. Still I think it’s a win for everyone that we’ve been able to make such a large and mostly seamless transition to open document formats.

This post originally appeared on my personal website here

Learn Linux Environment Variables Step-By-Step Easy Guide

July 12th, 2017 No comments

In the previous posts, we talked about some of the basic Linux commands, today we continue our journey, and we will talk about something very important in Linux which is Linux Environment Variables.

So what are Environment Variables and what is the benefit of knowing them?

Well, the bash shell uses a feature called Environment Variables to store some values which are required by the running programs or scripts from that shell, actually, this is a very handy way to store data and make it available for any script or a program when you run it from the shell.

There are two types of environment variables in the bash shell:

  • Global variables
  • Local variables

Global variables are visible from the shell session and for any running process that runs from the shell.

Local variables are visible in the shell that creates them.

Global variables

The Linux system sets some global environment variables when you log into your system and they are always CAPITAL LETTERS to differentiate them from user-defined environment variables.

To see these global variables, type printenv command:

printenv command

As you can see, there are a lot of global environment variables, to print only one of them, type echo command followed by $VariableName. Ex: to print HOME variable type echo $HOME.

home variable

Local variables

Actually, the Linux system also defines some standard local environment variables for you by default.

Unfortunately, there is no command that displays only local environment variables, but if you type the set command, you will see the global and local variables for the shell you are running and available to that shell.

Setting Local Environment Variables

You can set your own environment variables directly from the shell, once you open the shell you’re allowed to create local variables that are visible within your shell process. You just type variableName you want, followed by an equal sign and the variable value.

You just type variableName you want, followed by an equal sign and the variable value WITHOUT any spaces:

mysite=likegeeks

And to print the variable value, use the echo command:

echo $mysite

Sure enough, it prints likegeeks.

local environment variables

OK, what if your variable is more than one word; may be a long string, you can put the string between single quotations:

mysite=’likegeeks is a website that offers tech tutorials for geeks’

And if we type echo $mysite

set environment variables

If you forget the single quotation, the shell will assume that the second word is another command and will give you an error.

As you can see, I use lower case characters for my variable not upper case and this is recommended  NOT required, this helps you distinguishing your environment variables from the system environment variables.

Once you have set your local variable, it will be visible in the currently running shell scope and that means if you start another shell window the variable will not be available in that new window.

Setting Global Environment Variables

To create a global environment variable, you have to create a local environment variable then export it to the global environment like this:

myvar=’I will do it likegeeks’

echo $myvar

export myvar

global enviroment variables

As you can see I don’t use dollar sign with the export command so make sure of that.

But there is something, when I close the shell and open it again the variable is gone, so how to make it persistent?

Persisting Environment Variables

Just edit $HOME/.bashrc  and type   export myvar=‘welcome to likegeeks’  and save the file:

print persistent enviroment variable

Removing Environment Variables

This can be done by using the unset command:

unset enviroment variable

Default Shell Environment Variables

As we know, the system defines some variables for us, one of those variables is the PATH variable, this variable holds the paths of the directories that the shell uses to look for commands, each directory is separated by a colon.

Setting the PATH Environment Variable

If you to add a directory to the PATH variable, the shell will search in that directory also for an executable to run when you type any command.

Just append the path variable followed by a colon and the new directory like this:

add path to enviroment variable

And if you want to persist the PATH variable, you have to edit the .bashrc file and add type it like this:

persistent path variable

There is a useful trick that some sysadmins do which is adding a period . to the path variable so the shell will search for an executable in the current directory you are in wherever you are.

This is relatively risky, you might give the attacker the opportunity to run a malicious script or malware in his current directory, so if you do this trick, you should know what you are doing.

Locating System Environment Variables

There are three ways of starting a bash shell:

  • default login shell at login time
  • the interactive shell that is not the login shell
  • non-interactive shell to run a script

login shell

When you log into the Linux system, the bash shell starts as a login shell. The login shell looks.

There are four startup files that you can process the commands from:

  • /etc/profile
  • $HOME/.bash_profile
  • $HOME/.bash_login
  • $HOME/.profile

/etc/profile runs on every startup with every user, the other 3 files run for every specific user, you can call them user specific environment variables.

Interactive shell

If you start a bash shell without logging into a system like when you go to the rescue mode, this is the interactive shell.

If you start an Interactive shell, the system will not look for /etc/profile but instead will look for .bashrc in your HOME directory.

Non-interactive shell

This shell starts by the system to execute a shell script.

Users can customize the above-mentioned files to include environment variables and startup scripts for their own use, just edit the desired file and type the variable you want and save it.

Variable Arrays

One of the cool features of environment variables is that they can be used as arrays which hold multiple values.

myvar=(first second third fourth)

Now if you check the value of that array using echo command, you will find it returns the first element only.

To get a specific element, just reference it by its position, and the positions start from zero so to get the third one, type it like this:

echo ${myvar[2]}

To display the entire array type asterisk instead of a number:

echo ${mytest[*]}

variable array

You can remove an element of the array using unset command:

unset mytest[2]

Or you can remove the whole array:

unset myvar

This post was originally published on Like Geeks site here.

KWLUG: Rust (2017-07)

July 11th, 2017 No comments

This is a podcast presentation from the Kitchener Waterloo Linux Users Group on the topic of Rust published on July 10th 2017. You can find the original Kitchener Waterloo Linux Users Group post here.

To subscribe to the podcast add the feed here or listen to this episode by clicking here or choose from one of the following direct links:

You can find the original Kitchener Waterloo Linux Users Group post here.

Categories: Linux, Podcast, Tyler B Tags: ,

Basic Linux Commands Made Easy Part2

July 9th, 2017 No comments

In the previous post, we discussed some Linux commands and we saw how to show files, traverse directories, make them, and much more. Now, that was just the first level of the basic Linux commands. Let’s take one more step and see more of the basic Linux commands that you will use.

We talked about the ls command in the previous post and we’ve discussed only 2 parameters. Let’s dig deeper and see more parameters that can make you more powerful.

ls R  to recursively list all files in a directory

The -R parameter will traverse deeply till it finishes all directories. As you can see, for large directory structures, this can become quite a large output listing.

ls -R command

ls r  Reverses the sorting order for the displayed files and directories.

ls -r- command

ls S  Sorts the output by file size.

ls -lS command

ls t  Sorts the output by file modification time.

ls -lt command

Filtering Output

ls l myfile?

A question mark is used to represent one character.

ls l myprob*

An asterisk is used to represent zero or more characters.

The question mark and asterisk are called wild characters.

ls wild character

Creating Files

touch test1

The touch command is used to create an empty file. You can use the touch command to change the access and modification times of an existing file without changing the file contents.

touch command

If you use it against an existing file, it will change the access time, if the file doesn’t exist, it will create it.

In order to change the modification time,  just type it with -t followed by the time with the following format YYYYMMDDHHMM

touch t 202012011200 test1

touch existed file

Linking files

We know from the previous post that cp command is used to copy files.

What about creating a shortcut to that file in a different place. In Linux, this is called linking files.

There are two different types of file links in Linux:

  • hard link
  • symbolic, or soft link

cp l file1 file2

Hard Links

The hard link creates a separate file which contains information about the original file and where it is located.

Keep in mind that you can only create a hard link between files on the same physical drive, you can’t create hard links between files under separate mount points.

If you need to create links on a different physical drive, you’ll have to create a soft link instead.

cp hardlink

Symbolic Links

The -s parameter creates a symbolic or soft link:

cp s file1 file2

cp softlink

Here we should mention also another command that makes links other than cp which is ln command, you can create hard and soft links with it like this:

ln myfile myfile2

This command creates a hard link.

ln command

ln s myfile myfile2

This command creates a soft link.

ln softlink

Viewing the file type

file myfile

Determines the kind of the file.

file command

Viewing parts of a file

We know also from the previous post the cat command and the less command. Another important command that you will use a lot in your daily work which is the tail command.

The tail command

This command displays the last 10 lines of a file.

-n parameter to specify the number of lines

-f parameter to stay on the file and continue to watch the last lines you specified like monitoring, and this is very important when looking at log files.

tail command

The head command

Like tail command, but this command displays the first 10 rows of a file with the same tail command parameters.

head command

Running Processes

ps aux

This command is to see the currently running processes.

ps aux

top command shows the running processes.

-c parameter to show the command path that is running.

top command

kill command to kill a running process.

To kill a process

pkill processName

kill command

type xkill and press Enter to kill any nonresponsive window.

xkill command

 

df command shows the disk free space.

df h

-h for human readable value

df command

That was some of the basic Linux Commands. I hope you enjoy it. Keep coming back.

This post was originally published on Like Geeks site here.

Categories: LikeGeeks, Linux Tags:

Off to a rocky start with Zorin OS

July 2nd, 2017 No comments

In my previous post I mentioned that I installed Zorin OS onto an older laptop I had lying around.

Very nice first impression

Since that post went up I have been messing around with Zorin OS and decided to run a system update to make sure I had the latest packages and security fixes installed. Unfortunately after the update finished and I rebooted I logged in to find that things just weren’t what they used to be… Instead of the nice Zorin OS interface (shown above) I ended up logging in to a standard GNOME Shell interface. It seems as though the update had reset some of the customization that the Zorin team had made.

Thankfully I was able to find the Tweak tool and re-enable many of those customizations again!

Once I enabled all of the Zorin OS extensions almost everything was back to normal!

The one thing that I couldn’t get back to normal was the duplicate top bar showing open applications. You can see it in the screenshot above but basically I now had both the Zorin OS styled open window bar at the bottom as well as the GNOME Shell version at the top.

The solution it turns out is to turn off all of the Zorin OS extensions that I had tried in the tweak tool and instead open up the Zorin Appearance tool and select the first of the three window options at the top.

Both the first or second selections should work

The last key to the puzzle was to log out and then log back in for everything to take. And now my desktop is back to normal again!

Great success!

Distro hopping around DistroWatch challenge: Zorin OS

July 1st, 2017 No comments

I have an older Lenovo X60 laptop lying around that I don’t really use for anything these days and I decided that it might make for a decent computer to use to play around with some random distributions. It’s not the best machine in the world but does come packed with an Intel Core2Duo (T7200) @ 2GHz and 2GiB of RAM.

OK so it’s not the newest laptop in the world but it’ll do 🙂

OK so I have the machine and now to install a new distribution! …Unfortunately when I went to finally pick which distribution to actually install I couldn’t make up my mind and instead figured that I should first come up with an interesting way to help out with that process. So I went over to everyone’s favourite website DistroWatch.com and, after loading up their big list of distributions, I kind of just scrolled up and down while randomly moving the mouse for a while. Yeah not the most scientific approach but whatever. When I stopped my mouse was highlighting a link for Zorin OS and so the decision was made.

Designed for Windows XP but not limited to it!

I also came up with a simple rule for this round of distro hopping: stick to the base included software if possible. So for example if a distribution ships with Evolution as its e-mail client then use that instead of installing Thunderbird or something else. The point of this ‘rule’ is simply to try and use it in the way the packagers intended, rather than simply falling back to my standard set of software choices.

Very nice first impression

Zorin OS is a distribution that I’ve never actually used before and so this was a good first stop. According to its website it positions itself as:

“…the perfect blend of power and usability for everyone. Zorin OS was built to be as easy as possible, so you won’t need to learn a thing to get started thanks to its familiar user interface. It comes loaded with all the apps and tools you need out of the box for browsing the web, working, playing and everything in between.”

OK so let’s see what major software Zorin OS comes with by default:

I must say I’m actually quite impressed by this list. This is extremely close to what I would normally install on my systems and I think it will offer an excellent experience to Linux newcomers. I should also point out that even though it doesn’t look like it, Zorin OS is running on top of GNOME Shell and is actually based on Ubuntu so you inherit a lot of nice things (e.g. online help, PPAs, etc.) as a result.

Even something as boring as the menu is really, really nice!

My first impressions of Zorin OS in the brief time that I’ve used it so far are that the team spent a lot of time really polishing the presentation of their desktop. There is a lot of attention to detail here in the small things, for example how the logo fades in during boot or how the menu animates and slides as you move through it, that you just don’t find in a lot of other major distributions.

In terms of how it performs, even on this old laptop it seems pretty decent. On cold start it uses about 900 MiB of RAM which is a tad bit high but after a few hours of using it I was only up to around ~1.5 GiB or so which isn’t too bad.

I’ll be playing around with Zorin OS more over the coming days/weeks/whatever and will post anything interesting that I find as I go. Then it’ll be off to hop to another DistroWatch link. If you’re interested in joining me on this crazy made up challenge we would love to feature your write ups here at The Linux Experiment as well. Simply head over to this link and get in touch!