This is an useful trick specially when we have specific users for certain services - like app servers- the idea is to login temporally as another user in a terminal, do whatever you have to do and then logout, so, the steps are:
1. open a terminal
2. type: sudo -u myuser02 zsh
3. whoami
That's it, in this case, I use zsh as another terminal, you may use what you like.
Really useful, at least for me
Best
lunes, 27 de octubre de 2014
domingo, 26 de octubre de 2014
deploying Apache2+WebDAV on Ubuntu
WebDAV is a web authoring built into HTTP that allows to share files and work collaborative .
So, To enable it there are several steps, here they are:
1. enable the appropriated modules:
sudo a2enmod dav
sudo a2nemod dav_fs
2. restart apache:
sudo servide apache2 restart
3. Then we need to create a directory, it would be great whether this one is outside the DocumentRoot directory, i will create it on /home:
mkdir /home/me/webdav
4. To gain access from web we need to change the owner to www-data
chown www-data /home/me/webdav
5. Next, we need to password protect the target directory:
sudo htpasswd -c /etc/apache2/webdav.password me
sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password
6. Cool, now we need to configure apache to use WebDAV, I will modify the default site configuration file:
Alias /webdav /home/me/webdav
Order allow,deny
Allow from all
Options Indexes
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /etc/apache2/webdav.password
Require valid-user
7. At this time, we may try our advance, so from a web browser type:
http://localhost/webdav
You will be asked for a user and a password
You might try it using a WebDAV client called cadaver, like this:
cadaver http://localhost/webdav
8. for security reasons, we may disable the Directory Listing (removing the line Options Indexes) and instead, we may create an html file ( it is mandatory to named index.html), like this:
save it on /home/me/webdav, restart apache and try to access it
Next, I will write about how to use it in a production environment.
Best
So, To enable it there are several steps, here they are:
1. enable the appropriated modules:
sudo a2enmod dav
sudo a2nemod dav_fs
2. restart apache:
sudo servide apache2 restart
3. Then we need to create a directory, it would be great whether this one is outside the DocumentRoot directory, i will create it on /home:
mkdir /home/me/webdav
4. To gain access from web we need to change the owner to www-data
chown www-data /home/me/webdav
5. Next, we need to password protect the target directory:
sudo htpasswd -c /etc/apache2/webdav.password me
sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password
6. Cool, now we need to configure apache to use WebDAV, I will modify the default site configuration file:
Alias /webdav /home/me/webdav
Order allow,deny
Allow from all
Options Indexes
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /etc/apache2/webdav.password
Require valid-user
7. At this time, we may try our advance, so from a web browser type:
http://localhost/webdav
You will be asked for a user and a password
You might try it using a WebDAV client called cadaver, like this:
cadaver http://localhost/webdav
8. for security reasons, we may disable the Directory Listing (removing the line Options Indexes) and instead, we may create an html file ( it is mandatory to named index.html), like this:
Main Page
Main Page
this is the first page displayed once the directory listing is off
save it on /home/me/webdav, restart apache and try to access it
Next, I will write about how to use it in a production environment.
Best
sábado, 25 de octubre de 2014
executing commands using sudo without ask for password
Sometimes is annoying write the root password for execute certain commands, specially if you are working on console mode, that's why is really great to custom sudo ( using visudo) in order to avoid the password prompt:
1. open your terminal
2. type sudo visudo
3. then add these lines:
User_Alias MANAGERS = user1, user2
Cmnd_Alias SHUTDOWN = /sbin/reboot, /sbin/halt
4. Then add this line at the end of the file:
MANAGERS ALL = (ALL) NOPASSWD: SHUTDOWN
that's it, save it and try it
At least for me it works putting the NOPASSWD line at the end, I'm not sure if the way SUDO reads this file is from bottom to top, anyway, try it
Best
1. open your terminal
2. type sudo visudo
3. then add these lines:
User_Alias MANAGERS = user1, user2
Cmnd_Alias SHUTDOWN = /sbin/reboot, /sbin/halt
4. Then add this line at the end of the file:
MANAGERS ALL = (ALL) NOPASSWD: SHUTDOWN
that's it, save it and try it
At least for me it works putting the NOPASSWD line at the end, I'm not sure if the way SUDO reads this file is from bottom to top, anyway, try it
Best
lunes, 22 de septiembre de 2014
Cool tricks you can try on Google
Those are really cool and interesting tricks you can try on the Google Search Engine, at least for me, these next ones are most useful:
1. calculate tip!
tool to calculate the fees and tip per person.
2. Books by author name
easily you do a search about the books of your favorite author
3. Songs by singer name
I did not try it but I assume it will work as the previous one.
4. 100 usd to "currency name"
really cool!, there are a lot of currency
5. city to city distance
try it, it is really cool, unfortunately it did not work on some cities I tried.
there are more of them, you may try them here
Cool, see you
1. calculate tip!
tool to calculate the fees and tip per person.
2. Books by author name
easily you do a search about the books of your favorite author
3. Songs by singer name
I did not try it but I assume it will work as the previous one.
4. 100 usd to "currency name"
really cool!, there are a lot of currency
5. city to city distance
try it, it is really cool, unfortunately it did not work on some cities I tried.
there are more of them, you may try them here
Cool, see you
sábado, 20 de septiembre de 2014
ogv to mp4 without codec
This is a great trick, in fact yesterday it saved my life, I had an ogv file generated by gtk-recordmydesktop and I need to convert it to a mp4 file because the user do es not use GNU/Linux, so here it is the command line:
ffmpeg -i firstfile.ogv libx264 -vpre medium -crf 24 -threads 0 -acodec copy secondfile.mp4
As you can see we don't use any codec to export the format and this is really great - and faster- in order to get your file.
I read some howtos using codec such as libfaac but honestly it is not as quick as I need it, the result file was ok, I did not loose video quality and the audio was like the source one.
hope to help
Best
ffmpeg -i firstfile.ogv libx264 -vpre medium -crf 24 -threads 0 -acodec copy secondfile.mp4
As you can see we don't use any codec to export the format and this is really great - and faster- in order to get your file.
I read some howtos using codec such as libfaac but honestly it is not as quick as I need it, the result file was ok, I did not loose video quality and the audio was like the source one.
hope to help
Best
lunes, 15 de septiembre de 2014
enabling debug mode on your android phone
This is a really cool trick, I am developing an android app, the deadline is this next friday -hope can make it!- and tonight I start with the first checklist of test, so I got a bug but I could not see it from LogCat, that is really weird so I thought it was an isolated thing, I decided to try it again and still the same, but this time I read something on the LogCat window:
"Unable to open to open log device '/dev/log/main' no such file or directory"
So I discovered this bug occurs when the Android device turn this off. Googling about this would be some kind of complicated because there are many approaches, so I will show how I fix it, but remember, it is not sure it may work on your Android device:
0. My device is not rooted, it is a Huawei brand
1. dial this number on it:
"Unable to open to open log device '/dev/log/main' no such file or directory"
So I discovered this bug occurs when the Android device turn this off. Googling about this would be some kind of complicated because there are many approaches, so I will show how I fix it, but remember, it is not sure it may work on your Android device:
0. My device is not rooted, it is a Huawei brand
1. dial this number on it:
*#*#2846579#*#*
2. inmediately it will show a menu with 2 options: MMITest_II and ProjectMenu
3. Choose ProjectMenu
4. then Background Settings
5. Log Settings
6. in Log Switch choose "LOG on"
7. in Log level Setting choose "VERBOSE"
8. reboot your device
that's it, next time when you run your android app you will get all error messages from your device on the LogCat Window.
really cool ah!
Best
martes, 5 de agosto de 2014
speed up your chromebook with 'swap enable' command
Finally I could join many urls into my ChromeOS, I noticed my #Cromebook starts to behavior slowly, in fact I added like 30 tabs, so here is a command to speed up it:
1. from ChromeOS hit Ctrl+Alt+T
2. You'll get a new tab with Chrosh, it is like a gnome-terminal console
3. just type swap-enable
4. restart your #Chromebook
and that's all, next time, you'll notice the time to load all your tabs is shorter
PS: it is absolutely great to be here again, those past months I was really busy but it was really cool
Best
1. from ChromeOS hit Ctrl+Alt+T
2. You'll get a new tab with Chrosh, it is like a gnome-terminal console
3. just type swap-enable
4. restart your #Chromebook
and that's all, next time, you'll notice the time to load all your tabs is shorter
PS: it is absolutely great to be here again, those past months I was really busy but it was really cool
Best
Suscribirse a:
Entradas (Atom)