Posts Tagged ‘Linux & Unix’
How to prevent a Linux system user from loggin into the system
If a linux system user is able to login on the shell or with SSH depends on its shell setting in /etc/passwd. If you want to prevent that a certain user is able to login, then set the shell either to /bin/false or /sbin/nologin.
Example for Debian and Ubuntu Linux for the user with the username “otheruser”:
usermod -s /bin/false otheruser
For Redhat, Fedora or CentOS use /sbin/nologin:
usermod -s /sbin/nologin otheruser
Warning: Do not set the shell for the root user to /bin/false or /sbin/nologin!
How to convert filenames or text to lowercase on the shell
There is no simple tolower command on the bash, but with a little shell script you can convert uppercase characters to lowercase. The script uses the tr command internally for converting the chars.
Create a shell script with the name tolower:
vi /usr/local/bin/tolower
and enter the following content:
#!/bin/sh echo $1 | tr '[:upper:]' '[:lower:]' Then make the script executable: <p class="command">chmod +x /usr/local/bin/tolower
An test it by executing this command on the shell:
tolower "Thats a Test"
will convert the string to lowercase and show the result on the shell:
thats a test
Backup and restore mysql databases on the shell
One way to create a backup of a mysql database on the shell is to use the mysqldump command. Mysqldump creates a dump of the database in form of sql commands.
Backup
mysqldump -u root -p mydatabase > /tmp/backup_mydatabase.sql
This command creates a backup of the database with the name “mydatabase” in the file /tmp/backup_mydatabase.sql
Restore
To restore the backup, use the command:
mysql -u root -p mydatabase < /tmp/backup_mydatabase.sql
How to enable verbose logging in pure-ftpd on Debian Linux
To turn on verbose logging (e.g. to debug FTP connection or authentication problems) inĀ pure-ftpd FTP server on Debian and Ubuntu Linux, execute the following command as root user in the shell:
echo 'yes' > /etc/pure-ftpd/conf/VerboseLog
and then restart pure-ftpd
/etc/init.d/pure-ftpd-mysql restart
The debug output will be logged to syslog. To view the log content, execute:
tail -n 100 /var/log/syslog
To disable verbose logging, execute these commands:
rm -f /etc/pure-ftpd/conf/VerboseLog
/etc/init.d/pure-ftpd-mysql restart