ls -al | awk ' $7 >= 3 && $7 <= 27 && $8==2015 {print $9}' | xargs rm -f
Linux
Correct file permissions for WordPress
What permissions should I have for the following:
- root folder storing all the WordPress content
- wp-admin
- wp-content
- wp-includes
And then all the files in each of those folders?
Here is the correct file permissions for WordPress:
To set correct permissions you need to use these commands:
chown www-data:www-data -R * # Let apache be owner
find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r--
The following modules failed while saving their changes, their state is unknown: samba
I have an old desktop running Zentyal 3. I set it up as a file sharing machine and for more than a year it worked just fine. For some odd reason, the samba module stopped saving the ACLs and Zentyal threw the following error:
Some modules reported error when saving changes. More information on the logs
in /var/log/zentyal/
The following modules failed while saving their changes, their state is
unknown: samba
On a closer look in the zentyal.log file the following message captured my eye:
Failed to save changes in module samba: Could not get ticket: could not
acquire credentials using an initial credentials context: No ENC-TS found
After searching around a bit, I found the answer on a two year old bug on Zentyal bugtracker. I just had to run the next command as root:
samba-tool user setexpiry administrator --noexpiry
It would appear that the administrator password expired.
How to reset the MySQL root password
The following steps describe the procedure to reset the MySQL root password on Linux.
1) Stop the mysql server
/etc/init.d/mysql stop
2) Start the MySQL server manually without permission tables which allows us to login as root user without password:
mysqld_safe --skip-grant-tables &
3) Login into MySQL as root user without a password and switch to the “mysql” database:
mysql -u root mysql
Then execute this SQL query to set a new password for the MySQL root user:
update user set Password=PASSWORD('mynewpassword') WHERE User='root';
(Replace “mynewpassword” with the new root password in the above command).
Then logout from the MySQL prompt by typing:
exit
4) Now bring back the running mysql instance into the foreground by typing:
fg
and then press [ctrl] + c to kill the mysql process.
5) Start the mysql server again:
/etc/init.d/mysql start
CentOS Change Timezone
After installing CentOS we sometimes see that the date is not in our desired timezone, instead it defaulted to the PST timezone.
Correcting your timezone is an easy operation, so here is a quick guide to change your CentOS timezone configuration file.
Firstly you’ll need to know your timezone and/or country, a list can be found in /usr/share/zoneinfo/.
The more generic procedure to change the timezone is to create a symlink to file /etc/localtime
ln -sf /usr/share/zoneinfo/Europe/Bucharest /etc/localtime
OR you can copy and replace the current localtime setting
cp /usr/share/zoneinfo/Europe/Bucharest /etc/localtime
To verify that your timezone is changed use the date command:
date
Install Webmin on Ubuntu 14.04
Webmin is an open source, web based system administration tool for Unix/Linux. Using Webmin, you can setup and configure all services such as DNS, DHCP, Apache, NFS, and Samba etc via any modern web browsers. So, you don’t have to remember all commands or edit any configuration files manually.
Install Webmin On Ubuntu 14.04 LTS using official repository
Add the webmin official repository:
Edit file /etc/apt/sources.list
sudo vi /etc/apt/sources.list
Add the following lines:
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Add the GPG key:
sudo wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
Update the sources list:
sudo apt-get update
Install webmin using the following command:
sudo apt-get install webmin
Allow the webmin default port “10000” via firewall, if you want to access the webmin console from a remote system.
sudo ufw allow 10000
Access Webmin console
Open up your browser and navigate to the URL https://ip-address:10000/. The following screen should appear. Enter the user name and password to log in to webmin console.
What’s the default superuser username/password for postgres after a new install?
If you just installed postgresql 8.x/9.x and it has never asked you to create a superuser/password here is how to reset the default superuser and its password:
sudo -u postgres psql postgres
# \password postgres
Enter new password:
How to find a particular text string in Linux
You need to use the grep command. The grep command searches the given input FILEs for lines containing a match or a text string.
grep command syntax
The syntax is:
grep "text string to search" directory-path
or
grep [option] "text string to search" directory-path
or
grep -r "text string to search" directory-path
or
grep -r -H "text string to search" directory-path
or
egrep -R "word-1|word-2" directory-path
or
egrep -w -R "word-1|word-2" directory-path
How to measure actual memory usage of an application or process?
How do you measure the memory usage of an application or process in Linux as ps
is not an accurate tool to use for this intent.
Why ps is “wrong”?
Depending on how you look at it, ps is not reporting the real memory usage of processes. What it is really doing is showing how much real memory each process would take up if it were the only process running. Of course, a typical Linux machine has several dozen processes running at any given time, which means that the VSZ and RSS numbers reported by ps are almost definitely “wrong”.
With ps
or similar tools you will only get the amount of memory pages allocated by that process. This number is correct, but:
- does not reflect the actual amount of memory used by the application, only the amount of memory reserved for it
- can be misleading if pages are shared, for example by several threads or by using dynamically linked libraries
If you really want to know what amount of memory your application actually uses, you need to run it within a profiler. For example, valgrind
can give you insights about the amount of memory used, and, more importantly, about possible memory leaks in your program.
Setting locale to en_US.UTF-8 failed
While trying to install Owncloud I encountered the following error:
Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed
Please install one of theses locales on your system and restart your webserver.
For Debian Linux the solution is very simple, just run the following command:
dpkg-reconfigure locales
And mark at least one of the locales you need.