Displaying items by tag: tutorial

set_up_your_own_web_server.png 

 

The great thing about hosting is that similar to setting up your own site, you can make it as simple as you would like or you can get really complex, the reality is whichever method you choose is up to you. This is not a project for the faint of heart – indeed, you should be techy and much into the intricacy of hosting your own site. Someone who is interested in setting up their own server is a person with time to dedicate to this task and looks forward to the fulfillment of completing something that can be arduous even for the most tech-savvy.

Before getting into how to do your own hosting, you need to be aware of a few issues. Hosting your site requires a lot of electricity and you could deal with power outages, plus you are responsible for the efficacy and maintenance of hardware and software. Self-hosting has slower speeds than paid, dedicated hosts as well. However, the challenge of setting up your own hosting is invigorating, and a great next step on your tech journey.

Before you get started on hosting your own sites, it is a wise move to consider the benefits of paid hosting. The first thing you should know about paid hosting is generally things move faster on a paid host; these servers are dedicated to getting everything going and they don’t have the upload limitations that your ISP imposes upon you. That said, the other benefit a paid host has over self-hosting is that a paid host is responsible for the software and hardware. If anything goes wrong, you have to fix it instead of relying on the paid server company to perform maintenance. While sometimes it is easier to get any web hosting by simply paying with PayPal, the reality is hosting your own site is something for techy people that is really fun and as you improve in this endeavor, you develop skills that are quite marketable.

You can do web hosting with Windows and with Linux. Here is how with both systems.


 

 


Windows

 

Windows is not a popular way to host. The people who like Windows for hosting are those using ASP.NET or C# to code. If using these systems, Windows is the best option, despite being less popular than Linux.

 

Step 1: Get WAMP

One of the best installation programs is WampServer. This helps you work in Windows, Apache, PHP, and MySQL. Get the massive package when you download this, as the individual packages can be onerous and less accurate than the ones coming with WampServer. Once you get your WAMP, you can create subdirectories within it. Clicking on the Local Host link will take you to a URL that says, http://localhost in your main screen of WampServer.

 

Step 2: Simple Page Creation and Configuration of MySQL

As with anything, you want to test what you are doing. The next step is creating a new file with sample code. This could be something simple as a test using PHP. You can check in on this by going to the info section. However, if you click on phpMyAdmin, you can get going on configuring the MySQL information. This means the screen will open for admin credentials, but if you type in Admin to the log in name, rarely do you need a password. Once you get there, you can set and reconfigure your MySQL databases, and some CMS’s like WordPress do it for you.

 

Step 3: Make Your Site Public
Apache by default doesn’t want to make your site public, so you need to go in Apache and turn on the public settings. This will allow not just you to view your site, but the public as well.

 

Step 4: Domain Names
Setting up your DNS is not the easiest. What you do here is associate your IP address with a particular domain name. This will allow any DNS to pick out your domain name and download your site to get the information they need.


 


Linux

 

This is the most popular system used for web hosting. Learning about Linux will give you plenty of advantages while using a platform most folks are comfortable with.

 

Step 1: Use LAMP Software on the Terminal

The first thing you do with your terminal is to write a line of code to start your LAMP software installation. These tutorials will help you get started:

 

Step 2: Check if your PHP is Working

The way to test your PHP is to place a test file in the webserver root directory. Once there, you can visit the page by going to http://localhost/info.php. At this point, you’ll get a lot of information including the current version of PHP, configuration, and the installed modules. The good news is you can use Ubuntu to get the newest PHP modules. You can also use a simple command-line technique to get the same information as well.

 

Step 3: Get MySQL Under Control

Testing the MySQL for your site is imperative. This is especially important when you are using a CMS like Drupal, Joomla, or WordPress. Once there, you have to look at the server issue. Unfortunately, like the other servers, these one needs you to guide them. Most of the time, the system itself takes care of these MySQL databases. That said, you may have to enter some manually.

 

Step 4: DNS Configuration

Use the A record to get the IP address for your server using the dig tool. Once you do this, the next step is to associate your domain name with an IP address. The DNS step is vitally important because getting your domain associated with the IP means people won’t have to type in random numbers to see your site. Use Apache to set up the domain name, the index file, and any other files and set up permissions as well, and that gets your hosting done for you. You can use Namecheap to buy a domain name, read this review to help you decide.

This is just a short intro to self-hosting. You should do more research on security, setting up and maintaining servers, and a lot more. Though it’s a fun thing to do, it still requires a lot of skills and knowledge.

 

Published in Technology
Saturday, 30 May 2020 15:55

Ubuntu: How to install Apache

ubuntu-head-apache2.png 

These instructions should work on any Ubuntu-based distro, including Ubuntu 16.04, Ubuntu 18.04, and even non-LTS Ubuntu releases like 19.10.20.04+were tested and written for Ubuntu 18.04.

Apache (aka httpd) is the most popular and most widely used web server, so this should be useful for everyone.

 

Before we begin installing Apache
Some requirements and notes before we begin:

 

 

  • Apache may already be installed on your server, so check if it is first. You can do so with the “apachectl -V” command that outputs the Apache version you’re using and some other information.
  • You’ll need an Ubuntu server. You can buy one from Vultr, they’re one of the best and cheapest cloud hosting providers. Their servers start from $2.5 per month.
  • You’ll need the root user or a user with sudo access. All commands below are executed by the root user so we didn’t have to append ‘sudo’ to each command.
  • You’ll need SSH enabled if you use Ubuntu or an SSH client like MobaXterm if you use Windows.

That’s most of it. Let’s move onto the installation.

 

Install Apache on Ubuntu

The first thing you always need to do is update Ubuntu before you do anything else. You can do so by running:

apt-get update && apt-get upgrade
Next, to install Apache, run the following command:

apt-get install apache2
If you want to, you can also install the Apache documentation and some Apache utilities. You’ll need the Apache utilities for some of the modules we’ll install later.

apt-get install apache2-doc apache2-utils
And that’s it. You’ve successfully installed Apache.

You’ll still need to configure it.

 

Configure and Optimize Apache on Ubuntu
There are various configs you can do on Apache, but the main and most common ones are explained below.

 

Check if Apache is running
By default, Apache is configured to start automatically on boot, so you don’t have to enable it. You can check if it’s running and other relevant information with the following command:

systemctl status apache2

 apache-running.jpg

 

And you can check what version you’re using with

apachectl -V

A simpler way of checking this is by visiting your server’s IP address. If you get the default Apache page, then everything’s working fine.

 

Update your firewall

If you use a firewall (which you should), you’ll probably need to update your firewall rules and allow access to the default ports. The most common firewall used on Ubuntu is UFW, so the instructions below are for UFW.

To allow traffic through both the 80 (http) and 443 (https) ports, run the following command:

ufw allow 'Apache Full'

Install common Apache modules

Some modules are frequently recommended and you should install them. We’ll include instructions for the most common ones:

 

Speed up your website with the PageSpeed module
The PageSpeed module will optimize and speed up your Apache server automatically.

First, go to the PageSpeed download page and choose the file you need. We’re using a 64-bit Ubuntu server and we’ll install the latest stable version. Download it using wget:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

Then, install it with the following commands:

dpkg -i mod-pagespeed-stable_current_amd64.deb
apt-get -f install

Restart Apache for the changes to take effect:

systemctl restart apache2

Enable rewrites/redirects using the mod_rewrite module
This module is used for rewrites (redirects), as the name suggests. You’ll need it if you use WordPress or any other CMS for that matter. To install it, just run:

a2enmod rewrite
And restart Apache again. You may need some extra configurations depending on what CMS you’re using, if any. Google it for specific instructions for your setup.

Secure your Apache with the ModSecurity module
ModSecurity is a module used for security, again, as the name suggests. It basically acts as a firewall, and it monitors your traffic. To install it, run the following command:

apt-get install libapache2-modsecurity

And restart Apache again:

systemctl restart apache2

ModSecurity comes with a default setup that’s enough by itself, but if you want to extend it, you can use the OWASP rule set.

 

Block DDoS attacks using the mod_evasive module
You can use the mod_evasive module to block and prevent DDoS attacks on your server, though it’s debatable how useful it is in preventing attacks. To install it, use the following command:

apt-get install libapache2-mod-evasive

By default, mod_evasive is disabled, to enable it, edit the following file:

nano /etc/apache2/mods-enabled/evasive.conf
And uncomment all the lines (remove #) and configure it per your requirements. You can leave everything as-is if you don’t know what to edit.

 mod_evasive.jpg

And create a log file:

mkdir /var/log/mod_evasive
chown -R www-data:www-data /var/log/mod_evasive

 

That’s it. Now restart Apache for the changes to take effect:

systemctl restart apache2
There are additional modules you can install and configure, but it’s all up to you and the software you’re using. They’re usually not required. Even the 4 modules we included are not required. If a module is required for a specific application, then they’ll probably note that.

 

Optimize Apache with the Apache2Buddy script
Apache2Buddy is a script that will automatically fine-tune your Apache configuration. The only thing you need to do is run the following command and the script does the rest automatically:

 curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl

  

You may need to install curl if you don’t have it already installed. Use the following command to install curl:

apt-get install curl

Additional configurations
There’s some extra stuff you can do with Apache, but we’ll leave them for another tutorial. Stuff like enabling http/2 support, turning off (or on) KeepAlive, tuning your Apache even more. You don’t have to do any of this, but you can find tutorials online and do it if you can’t wait for our tutorials.

 

Create your first website with Apache
Now that we’re done with all the tuning, let’s move onto creating an actual website. Follow our instructions to create a simple HTML page and a virtual host that’s going to run on Apache.

The first thing you need to do is create a new directory for your website. Run the following command to do so:

mkdir -p /var/www/example.com/public_html
Of course, replace example.com with your desired domain. You can get a cheap domain name from Namecheap.

Don’t forget to replace example.com in all of the commands below.

 

Next, create a simple, static web page. Create the HTML file:

nano /var/www/example.com/public_html/index.html

And paste this:



Simple Page


If you're seeing this in your browser then everything works.




Save and close the file.

 

Configure the permissions of the directory:

chown -R www-data:www-data /var/www/example.com
chmod -R og-r /var/www/example.com

 

Create a new virtual host for your site:

nano /etc/apache2/sites-available/example.com.conf

 

And paste the following:


ServerAdmin This email address is being protected from spambots. You need JavaScript enabled to view it.
ServerName example.com
ServerAlias www.example.com

DocumentRoot /var/www/example.com/public_html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

This is a basic virtual host. You may need a more advanced .conf file depending on your setup.

Save and close the file after updating everything accordingly.

 

Now, enable the virtual host with the following command:

a2ensite example.com.conf

And finally, restart Apache for the changes to take effect:

systemctl restart apache2

That’s it. You’re done. Now you can visit example.com and view your page.

 

Published in GNU/Linux Rules!
Tagged under

LinuxHead

 

 

Guys, we are going to learn about the Package installation in Linux systems from this article. Basically how to install a package ( a package is  simply same as a software in a windows environment) and uninstalling it, what is a repository, how to create/enable/disable a repository, how the package installation commands change with different Linux distributions and so on.

What is a Package ?

Basically a package is a software application in a Linux operating system. Same as in windows and Mac OS, in Linux also we can install a software in a GUI environment as well as with the command line interface.

What is a Package manager ?

There are different package managers for different Linux distributions. It is very important to remember how to use different package installation commands in a Linux system. As we all know in a windows OS, we have softwares ending with .exe extension. But in Linux, the extensions may be different. It can be having an extension like .rpm, .deb or whatever.  Actually the package manager is serving as tool which access the softwares and installing/removing/modifying them.

dpkg is used by Debian, Ubuntu and apt is also supported.
rpm is used by Red Hat, Cent OS and yum is also supported.

 

* Important – You should be a superuser to install packages. 

So, for here testing i’m taking two AWS EC2 Linux servers ( Ubuntu and a Red Hat ). We will take one by one.

To get to know which Linux distribution you are using, try the below command,

cat /etc/*-release

 

 fedr1

 

Yum package manager

What is yum ? Yum is a command we can use to get the packages installed in a Red Hat, Cent OS environments. Yum is using repositories to search and install the applications.

What are Repositories ?

Red Hat or third party repositories are used as the software sources. In a repo we include links where the package managers can search for the packages.

Simply a repository looks like below.

 

fedr2

 

All repositories resides in the path “/etc/yum.repos.d“. The configuration file for yum is “/etc/yum.conf“.

From here, we will check the useful command we need to know.

1) yum repolist ( This command will list your active repositories )

 

fedr3

 

2) yum repolist all ( This will list all of your repositories even it is enabled or disabled )

 

fedr4

 

3) yum list installed ( This will list all your installed packages )

4) yum list vim* ( This will list installed and available packages which suits for package name )

 

fedr5

 

5) yum search vim ( This also searches with package names )

 

fedr6

 

yum search all  ( This gives more details than above )

6) yum info vim* ( This will display information about all the packages that suits the given name )

We can identify different parts in a package as below.

eg – vim-minimal.x86_64 : A minimal version of the VIM editor

vim-minimal – Package name
x86_64 – Architecture
*Sometimes we can see package version also with the names.
7) yum provides  ( This shows packages which contains the mentioned path names ). Not only path names, we can use application names also if we are not sure to check.
eg – yum provides tree

fedr7

 

yum provides /var/www/html

 

fedr8

 

8) yum install httpd ( This will install httpd package into the system )

 

fedr9

 

yum install httpd -y ( This command will install the package without asking for entering yes or no at the end. )

9) yum update  ( This will update the package to the latest version. )
10) yum remove  ( This will uninstall the installed package )
11) yum list kernel ( This will display installed and available kernel software versions )

 

fedr10

 

yum update kernel ( This will update the kernel to the latest version )

12) How to create a new repo
 
Go to the file location – /etc/repos.d
create your new repo – example.repo

fedr11

 

[examplerepo] – repo id

Example Repolist – repo name
baseurl – source url
enabled – status of the repo ( can be enabled or disabled )

 

fedr12

 

Apt package manager

 
Apt package manager is used in Ubuntu and Debian like Linux distributions.  Below listed commands would be helped.
apt actually works on a package database. The system will not know about is there are updates for the packages, if the package database is not updated. Because of this updating the package database is essential.
1) apt-get update ( This command will update the package database )
2) apt-get upgrade ( This will upgrade all the software to the latest version. )
3) apt-get install  ( This will install the package )
4) apt remove  ( This will remove the package binary file except configs)
5) apt purge  ( This will remove all files with the configuration files related to the package )
6) apt show  ( Display information about the package )
7) apt list  ( list the packages with the given name )
So, guys here are some of the basic very useful commands as in the above. You could know more than these commands with the usage.

 

Linuxfinal

Published in GNU/Linux Rules!
Wednesday, 26 February 2020 17:52

How to: Install jekins on your linux

Guys, Before talking about how to install jenkins on linux, shall we discuss a little bit about actually what is jenkins ? It is a automation tool which has written in java language. It is an open source application. Jenkins helps for automation tasks and mostly used by system administrators, cloud engineers, DevOps engineers and developers.

 

 

As an example if we take running Ansible playbooks on the ansible master node itself, we can use jenkins tool for running ansible playbooks. Since jenkins is a web tool, system

administrators/DevOps can easily use it taking the advantage of it’s different types plugins for specific purposes. Jenkins is also very useful for Continuos Integration and Continous delivery

(CI/CD ). Thanks to  jenkins, developers can build and test their software projects by doing the changes continously and can take the project to the production level without any distruption to the

users because of the pre testing stages running in continous delivery.

 

So we are going to see different ways of how to install jenkins on Linux.

 

1) Install Jenkins using yum command

commands :
sudo yum update -y
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo yum install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Note : Since Jenkins is a java application, first of all you must have installed java on your centos.

 jekins1.png

 

 command – sudo yum install java-1.8.0-openjdk-devel

 

 jenkins2.png

 

 We can check if the port for jenkins has opened. Remember that jenkins is using port 8080 as it’s default port. But we can change it if we need. 

 

jenkins3.png 

To access your Jenkins after the Installation, Open your web browser and got to your centos local ip

with port 8080 ( or localhost:8080 ) or if you are running a virtual machine your public ip with port 8080

could be accessed. I am here using the public ip attached to my virtual machine to get the jenkins web

interface. 

 

jenkins4.png

 

As shown in the browser you need to access that /var/lib path and get the Initial Admin password.

Then Install suggested plugins and login as admin ( if needed you can create another account ).

here we go, finally we have installed jenkins.

 

jenkins5.png 

 

 

2) Install Jenkins on a tomcat

What is tomcat ? Actually tomcat is a application server from apache foundation which executes java

servlets and renders the webpages which is having java coding. Since Jenkins is a tool build with

java, we are trying to install jenkins on tomcat.

 

commands :

sudo yum update -y
sudo yum install java-1.8.0-openjdk-devel
cd ~
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.0.M10/bin/apache-tomcat-9.0.0.M10.tar.gz
tar xzfv apache-tomcat-9.0.0.M10.tar.gz
mkdir Tomcat9
mv apache-tomcat-9.0.0.M10 Tomcat9
cd Tomcat9/bin
./startup.sh

Now  we have installed tomcat on one of our directories in home folder and started tomcat server. You

can check of the port 8080 has opened.

sudo netstat -plunt |grep 8080

Now open the browser with your localhost:8080 or if you are running a virtual machine then your vm

local machine ip with port 8080 or your public ip with port 8080.

 

 jenkins6.png

 

 Ok, now tomcat is ready to searve for java applications. Let’s get our jenkins into tomcat.

Download the jenkins war file from this link. Jenkins war releases. I use version 2.214 ( latest war file ).

commands :

cd ~/Tomcat9/webapps

wget http://updates.jenkins-ci.org/download/war/2.214/jenkins.war

 

jenkins7.png 

Now we will get back to the browser.

try now the url as your tomcat url/jenkins, like localhost:8080/jenkins

 

jenkins8.png 

 See now you are running your jenkins on tomcat. You can check the java process on the server. ps -ef|grep java

 

jenkins9.png 

 If you want to shutdown or restart the jenkins, you can do it by shutting down the tomcat node. Simply

do as below

cd ~/Tomcat9/bin


./shutdown.sh – this will shutdown the tomcat, so jenkins will also be shutdown


./startup.sh = this will start your tomcat and jenkins will be back online

 

 jenkins10.png

 

4) Install Jenkins on a docker container

commands :

First we need to install docker engine in our centos, So follow the below

sudo yum update -y


sudo yum install -y yum-utils device-mapper-persistent-data lvm2 -y

sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum -y install docker-ce

sudo systemctl start docker && sudo systemctl enable docker

now switch to root user – sudo su

 

To verify docker, use command docker ps and docker version to check the docker version.

 

jenkins11.png 

 Guys now we have installed docker on our centos. Now we will pull our jenkins image to our centos.

 

jenkins12.png

 

jenkins13.png

 

docker images

jenkins14.png

 

 Now i am creating a docker container from jenkins image as below

jenkins15.png

 

You can see that i have exposed the container to be accesible from the localhost ip from host port

8080. Open the browser and try to access the jenkins container with port 8080.

 

jenkins16.webp

 

So guys we discussed how to install jenkins on centos in three different ways. Hope more articles

related to jenkins on future.

 

Linuxfinal

Published in GNU/Linux Rules!
Tagged under

Try out furniture layouts, color schemes, and more in virtual reality before you go shopping in the real world.

 

There are three schools of thought on how to go about decorating a room:

  1. Buy a bunch of furniture and cram it into the room.
  2. Take careful measurements of each item of furniture, calculate the theoretical capacity of the room, then cram it all in, ignoring the fact that you've placed a bookshelf on top of your bed .
  3. Use a computer for pre-visualization.

 

 

Historically, I practiced the little-known fourth principle: don't have furniture. However, since I became a remote worker, I've found that a home office needs conveniences like a desk and a chair, a bookshelf for reference books and tech manuals, and so on. Therefore, I have been formulating a plan to populate my living and working space with actual furniture, made of actual wood rather than milk crates (or glue and sawdust, for that matter), with an emphasis on plan. The last thing I want is to bring home a great find from a garage sale to discover that it doesn't fit through the door or that it's oversized compared to another item of furniture.

It was time to do what the professionals do. It was time to pre-viz.

 

Open source interior design

Sweet Home 3D is an open source (GPLv2) interior design application that helps you draw your home's floor plan and then define, resize, and arrange furniture. You can do all of this with precise measurements, down to fractions of a centimeter, without having to do any math and with the ease of basic drag-and-drop operations. And when you're done, you can view the results in 3D. If you can create a basic table (not the furniture kind) in a word processor, you can plan the interior design of your home in Sweet Home 3D.

 

Installing

Sweet Home 3D is a Java application, so it's universal. It runs on any operating system that can run Java, which includes Linux, Windows, MacOS, and BSD. Regardless of your OS, you can download the application from the website.

  1. On Linux, untar the archive. Right-click on the SweetHome3D file and select Properties. In the Permission tab, grant the file executable permission.
  2. On MacOS and Windows, expand the archive and launch the application. You must grant it permission to run on your system when prompted.

sweethome3d.png  

On Linux, you can also install Sweet Home 3D as a Snap package, provided you have snapd installed and enabled.

 

Measures of success

First thing first: Break out your measuring tape. To get the most out of Sweet Home 3D, you must know the actual dimensions of the living space you're planning for. You may or may not need to measure down to the millimeter or 16th of an inch; you know your own tolerance for variance. But you must get the basic dimensions, including measuring walls and windows and doors.

Use your best judgment for common sense. For instance, When measuring doors, include the door frame; while it's not technically part of the door itself, it is part of the wall space that you probably don't want to cover with furniture.

 sweed-measre.jpg

 

Creating a room

When you first launch Sweet Home 3D, it opens a blank canvas in its default viewing mode, a blueprint view in the top panel, and a 3D rendering in the bottom panel. On my Slackware desktop computer, this works famously, but my desktop is also my video editing and gaming computer, so it's got a great graphics card for 3D rendering. On my laptop, this view was a lot slower. For best performance (especially on a computer not dedicated to 3D rendering), go to the 3D View menu at the top of the window and select Virtual Visit. This view mode renders your work from a ground-level point of view based on the position of a virtual visitor. That means you get to control what is rendered and when.

 

It makes sense to switch to this view regardless of your computer's power because an aerial 3D rendering doesn't provide you with much more detail than what you have in your blueprint plan. Once you have changed the view mode, you can start designing.

 

The first step is to define the walls of your home. This is done with the Create Walls tool, found to the right of the Hand icon in the top toolbar. Drawing walls is simple: Click where you want a wall to begin, click to anchor it, and continue until your room is complete.

 

sweetomed-wals.jpg

Once you close the walls, press Esc to exit the tool.

 

Defining a room

Sweet Home 3D is flexible on how you create walls. You can draw the outer boundary of your house first, and then subdivide the interior, or you can draw each room as conjoined "containers" that ultimately form the footprint of your house. This flexibility is possible because, in real life and in Sweet Home 3D, walls don't always define a room. To define a room, use the Create Rooms button to the right of the Create Walls button in the top toolbar.

 

If the room's floor space is defined by four walls, then all you need to do to define that enclosure as a room is double-click within the four walls. Sweet Home 3D defines the space as a room and provides you with its area in feet or meters, depending on your preference.

 

 

For irregular rooms, you must manually define each corner of the room with a click. Depending on the complexity of the room shape, you may have to experiment to find whether you need to work clockwise or counterclockwise from your origin point to avoid quirky Möbius-strip flooring. Generally, however, defining the floor space of a room is straightforward.

 

sweethome3d_rooms.jpg

 

After you give the room a floor, you can change to the Arrow tool and double-click on the room to give it a name. You can also set the color and texture of the flooring, walls, ceiling, and baseboards.

 sweethome3d-rooms_modify.jpg

 

None of this is rendered in your blueprint view by default. To enable room rendering in your blueprint panel, go to the File menu and select Preferences. In the Preferences panel, set Room rendering in plan to Floor color or texture.

 

 

Doors and windows

 

Once you've finished the basic floor plan, you can switch permanently to the Arrow tool.

You can find doors and windows in the left column of Sweet Home 3D, in the Doors and Windows category. You have many choices, so choose whatever is closest to what you have in your home.

 

 sweethome3d-move.jpg

 

To place a door or window into your plan, drag-and-drop it on the appropriate wall in your blueprint panel. To adjust its position and size, double-click the door or window.

 

Adding furniture

With the base plan complete, the part of the job that feels like work is over! From this point onward, you can play with furniture arrangements and other décor.

You can find furniture in the left column, organized by the room for which each is intended. You can drag-and-drop any item into your blueprint plan and control orientation and size with the tools visible when you hover your mouse over the item's corners. Double-click on any item to adjust its color and finish.

 

Visiting and exporting

To see what your future home will look like, drag the "person" icon in your blueprint view into a room.

 

 sweethome3d-view.jpg

 

You can strike your own balance between realism and just getting a feel for space, but your imagination is your only limit. You can get additional assets to add to your home from the Sweet Home 3D download page. You can even create your own furniture and textures with the Library Editor applications, which are optional downloads from the project site.

Sweet Home 3D can export your blueprint plan to SVG format for use in Inkscape, and it can export your 3D model to OBJ format for use in Blender. To export your blueprint, go to the Plan menu and select Export to SVG format. To export a 3D model, go to the 3D View menu and select Export to OBJ format.

You can also take "snapshots" of your home so that you can refer to your ideas without opening Sweet Home 3D. To create a snapshot, go to the 3D View menu and select Create Photo. The snapshot is rendered from the perspective of the person icon in the blueprint view, so adjust as required, then click the Create button in the Create Photo window. If you're happy with the photo, click Save.

 

Home sweet home

There are many more features in Sweet Home 3D. You can add a sky and a lawn, position lights for your photos, set ceiling height, add another level to your house, and much more. Whether you're planning for a flat you're renting or a house you're buying—or a house that doesn't even exist (yet), Sweet Home 3D is an engaging and easy application that can entertain and help you make better purchasing choices when scurrying around for furniture, so you can finally stop eating breakfast at the kitchen counter and working while crouched on the floor.

 

LICENSE

BannerFinalGNULINUZROCKS 

Published in GNU/Linux Rules!
Friday, 16 August 2019 19:35

GNOME desktop: Best extensions

BANNERGnulinuxrocks

 

Add functionality and features to your Linux desktop with these add-ons.

 

The GNOME desktop is the default graphical user interface for most of the popular Linux distributions and some of the BSD and Solaris operating systems. Currently at version 3, GNOME provides a sleek user experience, and extensions are available for additional functionality. We've covered GNOME extensions before, but to celebrate GNOME's 22nd anniversary, I decided to revisit the topic. Some of these extensions may already be installed, depending on your Linux distribution; if not, check your package manager.

 

 How to add extensions from the package manager
To install extensions that aren't in your distro, open the package manager and click Add-ons. Then click Shell Extensions at the top-right of the Add-ons screen, and you will see a button for Extension Settings and a list of available extensions.

  

To install extensions that aren't in your distro, open the package manager and clic Then clic Shell Extensions at the top-right of the Add-ons screen, and you will see a button for Extension Settings and a list of available extensions.

add-onsextensions_6.png

 

1. GNOME Clocks

GNOME Clocks is an application that includes a world clock, alarm, stopwatch, and timer. You can configure clocks for different geographic locations. For example, if you regularly work with colleagues in another time zone, you can set up a clock for their location. You can access the World Clocks section in the top panel's drop-down menu by clicking the system clock. It shows your configured world clocks (not including your local time), so you can quickly check the time in other parts of the world.

 

 

 

2. GNOME Weather

GNOME Weather displays the weather conditions and forecast for your current location. You can access local weather conditions from the top panel's drop-down menu. You can also check the weather in other geographic locations using Weather's Places menu.

 clocksweatherdropdown_6.png

 

GNOME Clocks and Weather are small applications that have extension-like functionality. Both are installed by default on Fedora 30 (which is what I'm using). If you're using another distribution and don't see them, check the package manager. You can see both extensions in action in the image below.

 

clocksweatherdropdown_6.png

 

 

3. Applications Menu
I think the GNOME 3 interface is perfectly enjoyable in its stock form, but you may prefer a traditional application menu. In GNOME 30, the Applications Menu extension was installed by default but not enabled. To enable it, click the Extensions Settings button in the Add-ons section of the package manager and enable the Applications Menu extension.

 

add-onsextensionsettings_6.png

 

Now you can see the Applications Menu in the top-left corner of the top panel.

 applicationsmenuextension_5.png

 

4. More columns in applications view
The Applications view is set by default to six columns of icons, probably because GNOME needs to accommodate a wide array of displays. If you're using a wide-screen display, you can use the More columns in applications menu extension to increase the columns. I find that setting it to eight makes better use of my screen by eliminating the empty columns on either side of the icons when I launch the Applications view.

 

Add system info to the top panel
The next three extensions provide basic system information to the top panel.

5. Harddisk LED shows a small hard drive icon with input/output (I/O) activity.
6. Load Average indicates Linux load averages taken over three time intervals.
7. Uptime Indicator shows system uptime; when it's clicked, it shows the date and time the system was started.

 

8. Sound Input and Output Device Chooser
Your system may have more than one audio device for input and output. For example, my laptop has internal speakers and sometimes I use a wireless Bluetooth speaker. The Sound Input and Output Device Chooser extension adds a list of your sound devices to the System Menu so you can quickly select which one you want to use.

 

9. Drop Down Terminal
Fellow writer Scott Nesbitt recommended the next two extensions. The first, Drop Down Terminal, enables a terminal window to drop down from the top panel by pressing a certain key; the default is the key above Tab; on my keyboard, that's the tilde (~) character. Drop Down Terminal has a settings menu for customizing transparency, height, the activation keystroke, and other configurations.

 

10. Todo.txt
Todo.txt adds a menu to the top panel for maintaining a file for Todo.txt task tracking. You can add or delete a task from the menu or mark it as completed.

todo.txtmenu_3.png

 

11. Removable Drive Menu
the editor Seth Kenlon suggested Removable Drive Menu. It provides a drop-down menu for managing removable media, such as USB thumb drives. From the extension's menu, you can access a drive's files and eject it. The menu only appears when removable media is inserted.

 

removabledrivemenu_3.png

 

12. GNOME Internet Radio
I enjoy listening to internet radio streams with the GNOME Internet Radio extension, which I wrote about in How to Stream Music with GNOME Internet Radio.

 

please read more at opensource.com

 

BannerFinalGNULINUZROCKS 

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

 

 

Linux is fully capable of running not weeks, but years, without a reboot. In some industries, that’s exactly what Linux does, thanks to advances like kpatch and kgraph.

For laptop and desktop users, though, that metric is a little extreme. While it may not be a day-to-day reality, it’s at least a weekly reality that sometimes you have a good reason to reboot your machine. And for a system that doesn’t need rebooting often, Linux offers plenty of choices for when it’s time to start over.

 

 

Understand your options

Before continuing though, a note on rebooting. Rebooting is a unique process on each operating system. Even within POSIX systems, the commands to power down and reboot may behave differently due to different initialization systems or command designs.

Despite this factor, two concepts are vital. First, rebooting is rarely requisite on a POSIX system. Your Linux machine can operate for weeks or months at a time without a reboot if that’s what you need. There’s no need to "freshen up" your computer with a reboot unless specifically advised to do so by a software installer or updater. Then again, it doesn’t hurt to reboot, either, so it’s up to you.

Second, rebooting is meant to be a friendly process, allowing time for programs to exit, files to be saved, temporary files to be removed, filesystem journals updated, and so on. Whenever possible, reboot using the intended interfaces, whether in a GUI or a terminal. If you force your computer to shut down or reboot, you risk losing unsaved and even recently-saved data, and even corrupting important system information; you should only ever force your computer off when there’s no other option.

 

 

Click the button

The first way to reboot or shut down Linux is the most common one, and the most intuitive for most desktop users regardless of their OS: It’s the power button in the GUI. Since powering down and rebooting are common tasks on a workstation, you can usually find the power button (typically with reboot and shut down options) in a few different places. On the GNOME desktop, it's in the system tray: 

gnome-menu-power.jpg

It’s also in the GNOME Activities menu:

gnome-screen-power.jpg

On the KDE desktop, the power buttons can be found in the Applications menu:

kde-menu-power.jpg

You can also access the KDE power controls by right-clicking on the desktop and selecting the Leave option, which opens the window you see here:

kde-screen-power.jpg

Other desktops provide variations on these themes, but the general idea is the same: use your mouse to locate the power button, and then click it. You may have to select between rebooting and powering down, but in the end, the result is nearly identical: Processes are stopped, nicely, so that data is saved and temporary files are removed, then data is synchronized to drives, and then the system is powered down.

 

 

Push the physical button

Most computers have a physical power button. If you press that button, your Linux desktop may display a power menu with options to shut down or reboot. This feature is provided by the Advanced Configuration and Power Interface (ACPI) subsystem, which communicates with your motherboard’s firmware to control your computer’s state.

ACPI is important but it’s limited in scope, so there’s not much to configure from the user’s perspective. Usually, ACPI options are generically called Power and are set to a sane default. If you want to change this setup, you can do so in your system settings.

On GNOME, open the system tray menu and select Activities, and then Settings. Next, select the Power category in the left column, which opens the following menu:

gnome-settings-power.jpg

In the Suspend & Power Button section, select what you want the physical power button to do.

The process is similar across desktops. For instance, on KDE, the Power Management panel in System Settings contains an option for Button Event Handling.

 

kde-power-management.jpg

 

After you configure how the button event is handled, pressing your computer’s physical power button follows whatever option you chose. Depending on your computer vendor (or parts vendors, if you build your own), a button press might be a light tap, or it may require a slightly longer push, so you might have to do some tests before you get the hang of it.

Beware of an over-long press, though, since it may shut your computer down without warning.

 

 

Run the systemctl command

If you operate more in a terminal than in a GUI desktop, you might prefer to reboot with a command. Broadly speaking, rebooting and powering down are processes of the init system—the sequence of programs that bring a computer up or down after a power signal (either on or off, respectively) is received.

On most modern Linux distributions, systemd is the init system, so both rebooting and powering down can be performed through the systemd user interface, systemctl. The systemctl command accepts, among many other options, halt (halts disk activity but does not cut power) reboot (halts disk activity and sends a reset signal to the motherboard) and poweroff (halts disk acitivity, and then cut power). These commands are mostly equivalent to starting the target file of the same name.

For instance, to trigger a reboot:

sudo systemctl start reboot.target

 

Run the shutdown command

Traditional UNIX, before the days of systemd (and for some Linux distributions, like Slackware, that’s now), there were commands specific to stopping a system. The shutdown command, for instance, can power down your machine, but it has several options to control exactly what that means.

This command requires a time argument, in minutes, so that shutdown knows when to execute. To reboot immediately, append the -r flag:

sudo shutdown -r now

To power down immediately:

sudo shutdown -P now

Or you can use the poweroff command:

poweroff

To reboot after 10 minutes:

sudo shutdown -r 10

The shutdown command is a safe way to power off or reboot your computer, allowing disks to sync and processes to end. This command prevents new logins within the final 5 minutes of shutdown commencing, which is particularly useful on multi-user systems.

On many systems today, the shutdown command is actually just a call to systemctl with the appropriate reboot or power off option.

 

Run the reboot command

The reboot command, on its own, is basically a shortcut to shutdown -r now. From a terminal, this is the easiest and quickest reboot command:

sudo reboot

If your system is being blocked from shutting down (perhaps due to a runaway process), you can use the --force flag to make the system shut down anyway. However, this option skips the actual shutting down process, which can be abrupt for running processes, so it should only be used when the shutdowncommand is blocking you from powering down.

On many systems, reboot is actually a call to systemctl with the appropriate reboot or power off option.

 

Init

On Linux distributions without systemd, there are up to 7 runlevels your computer understands. Different distributions can assign each mode uniquely, but generally, 0 initiates a halt state, and 6 initiates a reboot (the numbers in between denote states such as single-user mode, multi-user mode, a GUI prompt, and a text prompt).

These modes are defined in /etc/inittab on systems without systemd. On distributions using systemd as the init system, the /etc/inittab file is either missing, or it’s just a placeholder.

The telinit command is the front-end to your init system. If you’re using systemd, then this command is a link to systemctl with the appropriate options.

To power off your computer by sending it into runlevel 0:

sudo telinit 0

To reboot using the same method:

sudo telinit 6

How unsafe this command is for your data depends entirely on your init configuration. Most distributions try to protect you from pulling the plug (or the digital equivalent of that) by mapping runlevels to friendly commands.

You can see for yourself what happens at each runlevel by reading the init scripts found in /etc/rc.d or /etc/init.d, or by reading the systemd targets in /lib/systemd/system/.

 

Apply brute force

So far I’ve covered all the right ways to reboot or shut down your Linux computer. To be thorough, I include here additional methods of bringing down a Linux computer, but by no means are these methods recommended. They aren’t designed as a daily reboot or shut down command (reboot and shutdown exist for that), but they’re valid means to accomplish the task.

If you try these methods, try them in a virtual machine. Otherwise, use them only in emergencies.

 

 

Proc

A step lower than the init system is the /proc filesystem, which is a virtual representation of nearly everything happening on your computer. For instance, you can view your CPUs as though they were text files (with cat /proc/cpuinfo), view how much power is left in your laptop’s battery, or, after a fashion, reboot your system.

There’s a provision in the Linux kernel for system requests (Sysrq on most keyboards). You can communicate directly with this subsystem using key combinations, ideally regardless of what state your computer is in; it gets complex on some keyboards because the Sysrq key can be a special function key that requires a different key to access (such as Fn on many laptops).

An option less likely to fail is using echo to insert information into /proc, manually. First, make sure that the Sysrq system is enabled:

sudo echo 1 > /proc/sys/kernel/sysrq

To reboot, you can use either Alt+Sysrq+B or type:

sudo echo b > /proc/sysrq-trigger

This method is not a reasonable way to reboot your machine on a regular basis, but it gets the job done in a pinch.

 

Sysctl

Kernel parameters can be managed during runtime with sysctl. There are lots of kernel parameters, and you can see them all with sysctl --all. Most probably don’t mean much to you until you know what to look for, and in this case, you’re looking for kernel.panic.

You can query kernel parameters using the -–value option:

sudo sysctl --value kernel.panic

 

If you get a 0 back, then the kernel you’re running has no special setting, at least by default, to reboot upon a kernel panic. That situation is fairly typical since rebooting immediately on a catastrophic system crash makes it difficult to diagnose the cause of the crash. Then again, systems that need to stay on no matter what might benefit from an automatic restart after a kernel failure, so it’s an option that does get switched on in some cases.

You can activate this feature as an experiment (if you’re following along, try this in a virtual machine rather than on your actual computer

 

sudo sysctl kernel.reboot=1

 

Now, should your computer experience a kernel panic, it is set to reboot instead of waiting patiently for you to diagnose the problem. You can test this by simulating a catastrophic crash with sysrq. First, make sure that Sysrq is enabled:

 

sudo echo 1 > /proc/sys/kernel/sysrq

And then simulate a kernel panic:

sudo echo c > /proc/sysrq-trigger

Your computer reboots immediately.

 

Reboot responsibly

Knowing all of these options doesn't mean that you should use them all. Give careful thought to what you're trying to accomplish, and what the command you've selected will do. You don't want to damage your system by being reckless. That's what virtual machines are for. However, having so many options means that you're ready for most situations.

Have I left out your favorite method of rebooting or powering down a system? List what I’ve missed in the comments!

 

BOTONFACEBOOK COMMUNITY BOTONTELEGRAMCHANNEL

 Source: opensource.com Please visit and support the linux project.

BANNERLINUXFINALESPAOL

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

The passwords for user accounts often need to be changed. This is mostly done by the users themselves, but often, they have to be overridden by the administrator to

control any illegitimate activity by any of the users. Because of these reasons, Linux provides a wide range of options for user account password management.

We have discussed some of these useful options below:

 

 

Self password change:

The password of the user itself can be changed using the passwd command provided by Linux. This is how you can change the password of the user you’re logged in with. Just open up the command line, and type in: passwd  This will open up a prompt asking for the current password, and then the new password, and its repeated confirmation. The passwords aren’t shown in the terminal, so that they are not visible to any person that might be around the system.
 

password

Sample output:

pulkit@hostname:~$ passwd
Changing password for pulkit.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
pulkit@hostname:~$

 

 

Changing the password of another user

This requires root access, as only the root can add, remove or change the password of any other user on the system. You will need to know the administrator password. Therefore, the command becomes:

sudo passwd 

Sample output:

pulkit@hostname:~$ sudo passwd testuser
[sudo] password for pulkit: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
pulkit@hostname:~$

Or if you’re logged in with the “root” user you can just use the command without “sudo”.

  Checking password status

Seeing the status of a password is also made easy in Linux. There are a lot of criteria and properties that a password may have, and these are the commands that can be used to view those:

passwd -S 

 

Sample output:

pulkit@hostname:~$ passwd -S pulkit
pulkit P 04/15/2019 0 99999 7 -1
pulkit@hostname:~$

The displayed properties are as follows:

  • pulkit : User name
  • P : Password status:
    • P : Active password
    • L : Locked password
    • NP : No password
  • 04/15/2019 : Date of last password change
  • 0 : Password expiry minimum age
  • 99999 : Password expiry maximum age (99999 basically means never)
  • 7 : Password expiry warning period
  • -1 : Inactivity period (-1 means never)

This output is a bit cryptic. There is another command that displays this information in a better way. The syntax is as follows:

chage -l 

 

Sample output:

pulkit@hostname:~$ chage -l pulkit
Last password change : Apr 15, 2019
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
pulkit@hostname:~$

  Deleting a password

This option sets an account essentially password-less, so that anyone can log into it. This is not useful in most personal computers, but for a home PC, that’s what most people use, or for a system that needs to be open to anyone who attempts to use it, this option is essential. This command also requires root access. To delete the password of a user, use the following syntax:

sudo passwd -d 

 

Sample output:

pulkit@hostname:~$ sudo passwd -d testuser
[sudo] password for pulkit: 
passwd: password expiry information changed.
pulkit@hostname:~$

Force a user to change their password

This is a very useful feature, especially for Linux administrators. What this command basically does is expire the password of the mentioned user, so that the user has to forcefully change the existing password at their next login. This obviously requires root access as well. The command to be entered is this:

sudo passwd --expire 

 

Sample output:

pulkit@hostname:~$ sudo passwd --expire testuser
passwd: password expiry information changed.

su allows you to log in as another user.

pulkit@hostname:~$ su testuser
Password: 
You are required to change your password immediately (root enforced)
Changing password for testuser.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
testuser@hostname:/home/pulkit$

You can test these commands out on a Linux server at Vultr.

 Conclusion

That is all for the major operations regarding changing user passwords in Linux. Some of these options are exclusively for the root user, but that makes sense even for personal systems, as user management is often required in case of password loss, or something else of the sort. The root user is allowed to overpower any other user. The root account is not something to be played around with. You must always use the root account carefully.

Another common use-case is in servers. The upside to using a server is that in some cases you can still access the server via a web console, even if you locked yourself out of the server.

These instructions work for any Linux distro, including Ubuntu, CentOS, Debian, Fedora, etc.

BannerFinalGNULINUZROCKS

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

 

Users are arranged into different groups on all Linux-based systems. The whole idea behind this is that it makes the administration of the system easier, as the users can be arranged into different groups, and can be granted different permissions as required by the system administrator. The same user can be included in different groups, and the same file can be given different permissions based on the groups.

 

 

This article is about how to add a user to a group.

The instructions will work well on most Linux distros, including Ubuntu, CentOS, Debian, Fedora, Linux Mint, etc.

 

Different scenarios when adding a user to a group

 

Adding a user to a group has many factors to consider. Some are:

  • Existence of the user – The commands are usually different depending on whether the user already exists on the system,
  • Group category – The main group that the user belongs to is called the primary group. Generally, this group has the same name as that of the user. The other groups that the user belongs to are called the secondary groups. There are other groups too, that a user is not a part of, at all.
  • User permissions – This is a major factor, as only the super users can add any user to any given group. This permission limits the users in terms of which groups and which users they can edit.

Keeping all these factors in mind, we are only presenting two commands in order to add users to groups. But this is being shown considering that the user entering these commands is a super user/root (can perform sudo). These are the commands:

To add new users to groups

First, and the only exception, to add new users to groups:

sudo useradd -G  

The id command shows basic information about a user on the system. Therefore, to prove that the user doesn’t exist at first:

pulkit@hostname:~$ id testuser
id: ‘testuser’: no such user
pulkit@hostname:~$

Now we add a new user to an existing group:

pulkit@hostname:~$ sudo useradd -G pulkit testuser
pulkit@hostname:~$ id testuser
uid=1004(testuser) gid=1004(testuser) groups=1004(testuser),1000(pulkit)
pulkit@hostname:~$

All the remaining scenarios – when a user already exists

Now the only condition is that the user should already exist on the system. All the remaining scenarios can be worked out with this command:

sudo gpasswd -a  

If you want to remember this command, then you can create a new user before adding the user to the system. This can be done with:

sudo adduser 

Sample:

pulkit@hostname:~$ sudo adduser testuser
Adding user `testuser' ...
Adding new group `testuser' (1001) ...
Adding new user `testuser' (1001) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for testuser
Enter the new value, or press ENTER for the default
        Full Name []: 
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] y
pulkit@hostname:~$ sudo gpasswd -a testuser pulkit
Adding user testuser to group pulkit
pulkit@hostname:~$

Now checking if this worked:

pulkit@hostname:~$ id testuser
uid=1001(testuser) gid=1001(testuser) groups=1001(testuser),1000(pulkit)
pulkit@hostname:~$

Removing users from a group

This is not a part of adding users to groups, obviously, but an essential command to know if you’re managing groups. The command uses the same format as seen with the gpasswd command:

sudo gpasswd -d  

Sample:

pulkit@hostname:~$ sudo gpasswd -d testuser pulkit
[sudo] password for pulkit: 
Removing user testuser from group pulkit
pulkit@hostname:~$ id testuser
uid=1001(testuser) gid=1001(testuser) groups=1001(testuser)
pulkit@hostname:~$

 

This removes the user from the given group, as shown.

 

You can test these commands out on a Linux server at Vultr.

 

Conclusion

Adding users to groups on Linux is an easy task, if you know what commands to use. You can essentially do everything using just one command, as long as you know how to use it. The gpasswd command is the simplest command to use for the task. The useradd or usermodcommands can be used as well, but they have a comparatively more complex syntax, and therefore not recommended for beginners.

We hope this article served its purpose. Let us know if you have any questions in the comments below.

BannerFinalGNULINUZROCKS

Published in GNU/Linux Rules!

cool-linux-wallpaper-1.jpg

If you’ve come here looking to fix an errant recursive chmod or chown command on an RPM-based Linux system, then here is the quick solution. Run the following commands using root privileges:

rpm --setugids -a
rpm --setperms -a

The 

 

--setugids

 option to the rpm command sets user/group ownership of files in a given package.  By using the 

-a

 option we’re telling rpm to do this on all the packages. The 

--setperms

 option sets the permissions of files in the given package.

If this fixes your issue, great!  If not, or you want to be thorough, continue reading.

Why Would You Need To Fix the Permissions and User/Group Ownership of Files

The most common reason you’ll need to follow the procedure below is to recover from a chmod or chown command that didn’t do what you initially intended it to do.  Using this procedure can save you from having to perform a complete system restore or a complete system reinstall.

In any case, perhaps someone else accidentally executed a recursive chmod or chown command on part or even the entire file system.  Even if the mistake is noticed and the command is stopped by typing Control-C as quickly as possible, many files could have been changed in that short period of time and you won’t be able to immediately tell which files were changed.

Problems Caused by Incorrect Permissions and Ownerships of Files

Having improper file permissions or ownerships can cause processes and services to behave in unexpected ways, stop working immediately, or prevent them from starting once they’ve been stopped.

For example, if the user running the web server process can’t read the files it’s supposed to serve, then the service it provides is effectively broken.

If a service is already running, it probably doesn’t need to read its configuration file(s) again as it has that information in memory.  However, if it can’t read its configuration when it attempts to start, it simply isn’t going to start.

Also, when some services start, they create a lock file to indicate that the service is running.  When the service stops, it deletes the lock file. However, if the permissions on that lock file are changed while the service is running such that the service can’t delete the file, then of course the lock file won’t get deleted.  This will prevent the service from starting again as it thinks it’s already running due to the presence of the lock file.

Perhaps the file that actually needs to be executed no longer has execute permissions.  Needless to say, that will definitely keep a service from starting.

If you have a service such as a database that writes data, it needs the proper permissions to write data to file, create new files, and so on.

Those are some common issues you can run into when file permissions and ownerships are not set properly.

Examples of Errant chmod and chown Commands

A common way a chmod or chown command can go wrong is by using recursion while making a typing mistake or providing an incorrect path.  For example, let’s say you’ve created some configuration files in the /var/lib/pgsql directory as the root user. You want to make sure all those files are owned by the postgres user, so you intend to run this command:

chown -R postgres /var/lib/pgsql

However, you accidentally add a space between the leading forward slash and var, making the actual command executed this one:

chown -R postgres / var/lib/pgsql

Oh what a difference a space can make!  Now, every file on the system is owned by the postgres user.

The reason is because chown rightly interpreted the first forward slash ( “/” ) as an absolute path to operate upon and “var/lib/pgsql” as a relative path to operate on.  The chown command, and any Linux command for that matter, only does what you tell it to do. It can’t read your mind. It doesn’t know that you intended to only supply the one path of /var/lib/pgsql.

Fixing File Ownerships and Permissions with the RPM Command

Continuing with our example, you should be able to execute the following command with root privileges and return to a fairly stable state:

rpm --setugids -a

This command will return the owner and group membership for every file that was installed via an RPM package.  Changing the ownership of a file can cause the set-user-ID (SUID) or set-group-ID (GUID) permission bits to be cleared.  Because of this, we need to restore the permissions on the files as well:

rpm --setperms -a

Now every file that is known by rpm will have the same permissions as when it was initially installed.

By the way, use this same process to fix an errant chmod command, too.  Be sure to use the same order of the commands due the SUID and GUID issues that could arise.  IE, run rpm with the 

--setperms

 options last.

Fixing File Ownerships and Permissions for Files Not Known by RPM

Not all the files on the system are going to be part of an RPM package.  Most data, either transient or permanent, will live outside of an RPM package.  Examples include temporary files, files used to store database data, lock files, web site files, some configuration files, and more depending on the system in question.

At least check the most important services that the system provides.  For example, if you are working on a database server, make sure the database service starts correctly.  If it’s a web server, make sure the web server service is functioning.

Here is the pattern:

systemctl restart SERVICE_NAME

If the service does not start, determine the reason by looking at the logs and messages:

journalctl -xe

Fix any issues and try again until the service starts.

Example:

systemctl restart postfix
# The service fails to start.
journalctl -xe
# The error message is “fatal: open lock file /var/lib/postfix/master.lock: cannot open file: Permission denied”
# Fix the obvious error.
rm /var/lib/postfix/master.lock
# Make sure there aren't other files that may have permissions or ownership issues in that directory.
ls -l /var/lib/postfix
# There are no other files.
# Try to start the service again.
systemctl start postfix
# No errors are reported.  The service is working! Lets double-check:
systemctl status postfix

You can check which services are in a failed stated by using the following command.

systemctl list-units --failed

Let’s say you reboot the system and want to make sure everything started ok.  Then run the above command and troubleshoot each service as needed.

Also, if you have good service monitoring in place, check there.  Your monitors should report if any service isn’t functioning appropriately and you can use this information to track down issues and fix them as needed.

A List of Directories that Are Not in the RPM Database

Here are some common places to look for files that live outside of an RPM package:

/var/log/SERVICE_NAME/  (Example: /var/log/httpd)
/var/lib/SERVICE_NAME/  (Example: /var/lib/pgsql)
/var/spool/SERVICE_NAME/  (Example: /var/spool/postfix)
/var/www
/usr/local
/run
/var/run/
/tmp
/var/tmp
/root
/home

Correcting Home Directory Ownership

If user home directories were changed do to a recursive chmod or chown command, then they need to be fixed.  If the ownership has changed, we can make an assumption that each home directory and all of its contents should be owned by the corresponding user.  For example, “/home/jason” should be owned by the “jason” user and any files in “/home/jason” should be owned by the “jason” user, too. Here’s a quick script to make this happen:

cd /home
for U in *
do
chown -R ${U} ${U}
done

Be careful with the chown command because we don’t want to create another mess!

It could be the case that some files in a given home directory should not be owned by the user.  If you think this might be the case, your best course of action is to restore the home directories from backups.  Speaking of which…

Why Not Just Restore from Backup?

If you have a good and recent backup, restoring that backup might be a great option.  If the server in question doesn’t actually store data, then it would be a perfect candidate for a restore as you won’t lose any data.

Performing a restore can give you the peace of mind that all the files on the system have the proper permissions and ownership.  After you’ve rigorously checked the services, the chances of any missed files causing operational issues is low. Nevertheless, there is a possibility of an issue arising at a later date.  A restore reduces this probability even further.

You could also use a hybrid approach where you run through the above process and selectively restore parts of the system.

The downside of performing a restore is that it can be slower that using the process outlined above.  It’s much quicker to change the permissions on a 1 TB file than it is to restore that file.

Of course, if you don’t have a backup that you can restore then you will have to follow a process like the one outlined above.

Marielle Price

Published in GNU/Linux Rules!
Page 1 of 2