jump to navigation

To Create a Self-Extracting Zip January 17, 2009

Posted by ModelR in General Computer Related.
add a comment

Create a self extracting zip

Advertisements

Script To Fix eth0 After Moving VM January 11, 2009

Posted by ModelR in UBUNTU LAMP Project.
add a comment
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

Download a copy of the script to look over: fixeth0.sh in text format

Create a new file called “/usr/local/bin/fixeth0.sh:
$ sudo nano /usr/local/bin/fixeth0.sh

#!/bin/bash
# Script to fix eth0 as a result of moving the VM
echo ""
echo "************************************"
echo "*VM HAS MOVED NOW WE'RE FIXING ETH0*"
echo "************************************"
echo ""
if [ $(id -u) -eq 0 ]; then
sudo rm /etc/udev/rules.d/70-persistent-net.rules
sudo shutdown -r now
else
echo "Only root can delete a user from the system"
exit 2
fi

Make the script executable
$ sudo chmod 755 /usr/local/bin/fixeth0.sh

Script To Delete A User January 11, 2009

Posted by ModelR in UBUNTU LAMP Project.
add a comment
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

Download a copy of the script to look over: removeuser.sh in text format

Create a new file called “/usr/local/bin/removeuser.sh:
$ sudo nano /usr/local/bin/removeuser.sh

#!/bin/bash
# Script to remove a user to Linux system
echo ""
echo "******************************"
echo "*Delete a user from the system*"
echo "******************************"
echo ""
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
read -p "Delete $username from the system? Type YES To delete: " confirm
if [ "$confirm" == "YES" ]; then
smbpasswd -x $username
deluser $username
rm -rf /home/$username
echo ""
echo ""
echo "$username successfully removed from the system."
echo ""
else
echo ""
echo "$username was not deleted."
echo ""
exit 1
fi
else
echo ""
echo "$username does not exist"
echo ""
fi
else
echo "Only root can delete a user from the system"
exit 2
fi

Make the script executable
$ sudo chmod 755 /usr/local/bin/removeuser.sh

Script To Create New Users January 11, 2009

Posted by ModelR in UBUNTU LAMP Project.
add a comment
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

Download a copy of the script to look over: newuser.sh in text format

Create a new file called “/usr/local/bin/newuser.sh:
$ sudo nano /usr/local/bin/newuser.sh

Edit the file with the following:
#!/bin/bash
# Script to add a user to Linux system
echo ""
echo "******************************"
echo "*Add a new user to the system*"
echo "******************************"
echo ""
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username already exists!"
exit 1
else
#CREATE THE USER
sudo useradd -d /home/$username -m $username
echo ""

#SET THE UNIX PASSWORD FOR THE USER
echo "Create a SYSTEM password for $username"
let done=0
while [ $done -eq 0 ]; do
passwd $username
echo ""
egrep "^$username\:!:" /etc/shadow >/dev/null
if [ $? -eq 0 ]; then
echo " Could not create a SYSTEM password for $username."
echo " Please try again."
echo ""
else
let done=1
echo " SYSTEM password for $username was successfully created."
echo ""
fi
done

#CREATE THE public_html DIRECTORY AND CHANGE OWNERSHIP TO USER
mkdir /home/$username/public_html
chown $username:$username /home/$username/public_html

#ADD THE APACHE USER ACCOUNT TO THE USER'S GROUP
sudo usermod -a -G $username www-data

#SET THE PASSWORD FOR MYSQL AND SAMBA
echo "Create a MySQL and Samba password"
let done=0
while [ $done -eq 0 ]; do
read -s -p "MySQL & Samba Password: " PASS1
echo ""
read -s -p "Confirm the MySQL & Samba password: " PASS2
echo ""
echo ""
if [ "$PASS1" == "$PASS2" ]; then
let done=1
#CREATE THE MYSQL AND SAMBA PASSWORD
echo "Creating the Samba User and Password"
smbpasswd -e $username
(echo $PASS1; echo $PASS1) | smbpasswd -s -a $username
echo "Please enter the MySQL root password to complete the user setup"

echo ""

echo " MySQL & Samba password successfully created for $username."
echo ""
else
echo "The passwords do not match, please try again."
echo ""
fi
done

#FINISH
echo " $username was successfully created."
echo ""

echo ""
echo "***********************"
echo "RESTARTING APACHE"
sudo /etc/init.d/apache2 restart
echo "***********************"
echo ""

echo ""
echo "***********************"
echo "*Your home directory is /home/$username"
echo "***********************"
echo ""
echo "**********************"
echo "*Your Web directory is /home/$username/public_html"
echo "**********************"
echo ""
echo "******************************"
echo "*The Samba share directory is" '\\'$(hostname)'\'"homes"'\'
echo "******************************"
echo ""
fi
else
echo "Only root may add a user to the system"
exit 2
fi

Make the script executable
$ sudo chmod 755 /usr/local/bin/newuser.sh

Enabling Samba Shares January 11, 2009

Posted by ModelR in UBUNTU LAMP Project.
add a comment
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

To enable each user access to their Samba shares over the network, we will have to edit the Samba configuration file located here: /etc/samba/smb.conf

Before we begin we will create a backup
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.master

Erase the entire contents of smb.conf and add the following:
#======================= Global Settings =======================
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
####### Authentication #######
security = user
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n$
pam password change = yes
map to guest = bad user
########## Printing ##########
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
############ Misc ############
socket options = TCP_NODELAY
#======================= Share Definitions =======================
[homes]
comment = Home Directories
browseable = yes
read only = no
create mask = 0755
valid users = %S

Restart the samba server
$ sudo /etc/init.d/samba restart

phpMyAdmin Multiple Users Setup January 11, 2009

Posted by ModelR in UBUNTU LAMP Project.
2 comments
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

Also see this website for more options: Configuring phpMyAdmin for multiple users

The goal that we wish to achieve, is to allow multiple users to use phpMyAdmin only seeing and having permissions for their own databases. The root user will be able to see all databases. To get to this goal we will have to make a few changes to the config file located here: /etc/phpmyadmin/config.inc.php

Before we begin we will make a backup of the file before editing it
$ sudo cp /etc/phpmyadmin/config.inc.php /etc/phpmyadmin/config.inc.php.master

Here is what will have to be changed:
Uncommented the following
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

Uncommented and changed mysql to mysqli in the following line
$cfg['Servers'][$i]['extension'] = 'mysqli';

After this line
// $cfg[‘Servers’][$i][‘controlpass’] = ‘pmapass’;
We added this
$cfg['Servers'][$i]['hide_db'] = 'information_schema';

Then we added this line as the last line
$cfg['AllowUserDropDatabase'] = true;

That’s it.

Trouble Connecting To A Share With Another Username January 10, 2009

Posted by ModelR in Everything WINDOWS.
add a comment

Are you getting this annoying error???

Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resoure and try again.

Try this command:
net use <sharename> /delete

This command should delete the current connection so that you can start a new one.

your welcome.

Quick Command Reference January 9, 2009

Posted by ModelR in Everything LINUX.
add a comment

Get a dhcp address

sudo dhclient

List samba users

pdbedit -Lw
or
cat /etc/samba/smbpasswd

List process that are currently running
ps aux

Location of the groups file
/etc/group

Location of the passwords file
/etc/passwd

file permission settings
rwx
owner | group | other
***************************************
Best place to store Linux shell scripts that you create
/usr/local/bin

Add a user to a group
usermod -a -G mygroupname myusername

Check if a user already exists
grep <username> /etc/passwd

OR
id <username>

if your using it as a check in a script you can use this command so it doesn’t print anything on the screen:
egrep "^$username" /etc/passwd >/dev/null

Check if a user has a password
grep <username> /etc/shadow

The mv command can be used for moving or renaming files. To rename a file, you can use it like this:
$ mv file file2

List user groups
cat /etc/group

Changing ownership of a target directory etc.
chown [-R] [[user]][:group] target1 [[target2 ..]]
example
chown username:group change.txt

Remove a non-empty directory (use this command with caution)
rm -rf directory/

Copying files
cp <file> <destination>

Sed command -> for replacing text
The following command pipes the contents of /etc/hostname to the sed command
The sed command then replaces whatever in the file that has the name jeos-lamp with jeos-lamp2, then writes it to the file /etc/hostname
cat /etc/hostname | sed -e 's/jeos-lamp/jeos-lamp2/' > /etc/hostname2
OR
Use this version if you are creating a script
cat /etc/hosts | sed -e {'s/'$(hostname)'/'$newhost'/'} > /etc/hosts2

To find out what user you are logged in as
whoami

To find out your current directory location (print working directory)
pwd

To list files
ls

To list files one per line with the attributes
ls -la

To delete a file
rm <filename>

To fill in command prompts automatically (example is for adding a password to samba)
(echo $password; echo $password) | /usr/bin/smbpasswd -s -a $username