What is Saltstack and How to Install It
In this tutorial you will know what is Salt, how to install it and a Quick commands to get you started.
What is Salt ?
Salt is an infrastructure and package management tool, it will help you to automate packaging, infrastructure installation and package management.
Salt is a different approach to infrastructure management, founded on the idea that high-speed communication with large numbers of systems can open up new capabilities. This approach makes Salt a powerful multitasking system that can solve many specific problems in an infrastructure.
The backbone of Salt is the remote execution engine, which creates a high-speed, secure and bi-directional communication net for groups of systems. On top of this communication system, Salt provides an extremely fast, flexible, and easy-to-use configuration management system called Salt States.
Find If Package Needs to be Updated
In this tutorial I will show you some surviving commands to find if a package needs to be updated.
Check Package Version
yum list installed | grep -i httpd
Hands On Linux Commands for Real Life
In this series I will be discussing practical Linux commands you use in real life with it's parameters and options, I will
go through the options and clarify them without digging deep and turn simple stuff into rocket science.
Also will not go through the command in specific order because this course is meant to be for people who are
refreshing their memory or starting to learn the commands so it will be good to go back to the command and see different
options from time to time. Continue reading
To give a user access to a certain folder in Linux you don't have to change the permissions globally for that folder, instead you can use 'setfacl' for that.
Give user mike a full access to dotsway folder:
[root@hostname ~]# setfacl -m u:mike:rwx /home/dotsway/
Check users and groups access permissions to certain folder:
[root@HOSTNAME ~]# getfacl /home/dotsway/
getfacl: Removing leading '/' from absolute path names
# file: home/dotsway
# owner: dotsway
# group: it
Remove user access from folder
setfacl -x u:mike /home/dotsway
You can always check what are in your path environment by running:
Below example will add /usr/local/go/bin to environment, open now your own bashrc and add the following at the end of the file:
To reload that environment file you can run:
Now if you echo again the path go should be at the end.
Find oldest files within the same folder:
ls -lat | tail -n5
Above command will list all the files in a specific folder while sorting it by modified time using 'ls -lat', the using the pipe symbol to send the output to another command.
Tail -n5 will show only the last 5 results.
How to find oldest files recursively ? (Through the chain of folders' tree/hierarchy)
Your bet is using 'find' command as it searches recurrsively by default, but let us see how to use it's parameters
-type f is used to specify the search type which is file in that case, so in other cases you need to use -type d for directories only
-printf is used to output, and we will use %t to print time and %p to prnt filename while '\n' means new line
sort yes you got it right it's going to sort the output
head -n5 now you can use head to get the top files in the output or use 'tail -n5' or get the opposite while -n5 is the number of output files you want to show, so if you use 'head -n1' it will show only one file.
find /home/dotsway/ -type f -printf '%t+ %p\n' | sort | head -n 5
Fri Apr 29 10:45:15.0891747285 2016+ /home/dotsway/php.ini
Fri Aug 12 12:19:55.0110672762 2016+ /home/dotsway/php-modules-AfterNaviSiteRecompile.txt
Fri Aug 19 11:21:06.0000000000 2005+ /home/dotsway/perl/MKDoc-Text-Structured-0.83/README
Ever installed any incompatible libraries to your RedHAT/CentOS system and got stuck ?! Don't worry we all did in some certain points, you can fix it by following the below method:
Reboot the machine into rescue mode
Unset the LD_LIBRARY_PATH so system not to use the third party libraries or the current ones.
Then install the right libraries for your system flavor and edition (below example is for glibc) :
(It's better to use --test for testing and check for errors before applying to system)
rpm -ivh file.rpm --test --force --noscripts --root=/mnt/sysimage
rpm -ivh glibc-<version>.rpm --force --nodeps --root=/mnt/sysimage
If your system is still running and you are using CentOS 7 then just type the below command, if you cannot access the command line then proceed to #2:
This will reboot the main system to rescue mode and ask you for the root password.
First reboot your system using either hard reboot or soft reboot, then pause the menu by moving up and down with cursor, then you need to hit 'e' to edit the parameters, you will see similar screen to below:
Type at the end of the line and before the initrd 'rescue' like below and then press or if you are using CentOS 7 then type 'systemd.unit=rescue.target' then hit 'ctrl+x' to continue with modified parameters
Ever seen 's' or 'S' in the Linux file permissions ?
'S' = The directory's setgid bit is set, but the execute bit isn't set.
's' = The directory's setgid bit is set, and the execute bit is set.
What is setgid ?
When user creates a folder or a file under a setgid folder, the new file/folder will inherit its group as the group of the folder's owner, instead of the group of the user who creates it.
So in above screenshot, all files/folders created inside /screen will have same 'screen' group.
How to change 's' permissions using chmod ?
chmod g-s /folder/file "remove"
chmod g+s /folder/file "add"
Upgrade glibc 2.12 to 2.14 , in some cases to install above modules the glibc 2.14 will be needed
PS: Please don't do this unless you know what you are doing as this could corrupt your system if you copied different structure files to your lib folder.
By default in CentOS/RedHAT 6.x glibc 2.12 is installed but some modules and libraries require glibc 2.14, below is a walkaround steps (PS Below tar file is for 32 Bit) :
1. Start Terminal under current user.
2. Use command: su – and type root password
3. cd /home/user/Downloads
4. wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
5. tar zxvf glibc-2.14.tar.gz
6. cd glibc-2.14
7. mkdir build
8. cd build
9. ../configure --prefix=/opt/glibc-2.14
10. make -j4
11. make install
12. export LD_LIBRARY_PATH=/opt/glibc-2.14/lib
This was tested on CentOS 6.7 32 Bit