Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, November 23, 2009

Forgot root password

Forget your root password?
On Red Hat/Centos most any linux box:

1. Get physical access to the box
2. reboot it
3. during the grub menu, type e
4. go down to the line that has 'quiet' in it, usually that's the one I use but it doesnt'really matter. what you are basically going to do is type single at the end of whatever line you want to boot.

*this will also walk you though it
http://www.cyberciti.biz/faq/grub-boot-into-single-user-mode/


5. this will dump you to single user mode, and you can just do passwd to set new root password

Wednesday, September 30, 2009

Linux Find Command find text in files

To find the text "JoomlArt" in all files in all subdirectories under the current dir, use this:

find . -type f -name "*" -exec grep -il JoomlArt {} \;

If you just wanted to search in php file for example, it would be this:

find . -type f -name "*.php" -exec grep -il JoomlArt {} \;

(grep is not needed in these examples)

Thursday, September 24, 2009

DirectAdmin forgot admin password?

If you forget the Direct Admin admin password, all you have to do is if you have ssh to the box as root type:

passwd admin

(then reset it you goof!)

Monday, August 31, 2009

exim permissions error

When I see this:

login as: root
root@64.254.200.10's password:
Last login: Mon Aug 31 15:44:06 2009 from adsl-70-131-140-218.dsl.emhril.sbcglob al.net
[root@ls3 ~]# 2009-08-31 15:45:42 1MiDl0-0001b0-SA Failed to create spool file / var/spool/exim/input//1MiDl0-0001b0-SA-D: Permission denied
[root@ls3 ~]#


I do this (temporarily):
chmod -R 777 /var/spool/exim
because this does not work:
chmod -R 755 /var/spool/exim

Thursday, August 20, 2009

Remove 'Welcome to the Frontpage' title in Joomla! 1.5

How to remove 'Welcome to the Frontpage' title in Joomla! 1.5
Navigation
• •
If you install new Joomla! 1.5 on your server, you get the 'Welcome to the Frontpage' title on your Frontpage. Sometimes, it is difficult to find, where you can change this title.

Go to your Joomla! 1.5 Administration site and login. In your administration site go to:

Menus - Main Menu (now you are in: Menu Item Manager: mainmenu).
Click on 'Home' link to edit this link (you are now in: Menu Item: Edit).
Click on Parameters System and change or delete the Page title.
If you change the Page title, changed title will be displayed on your Frontpage as a title.
If you delete the Page title, Menu link will be displayed on your Frontpage as a title (in the present case 'Home' will be displayed as title, because 'Home' is the name of the link to the Frontpage).
If you don't want to display any title, set Show Page Title below Page title parameter to 'No'.
Don't forget to save changes.

Tuesday, August 18, 2009

Transfer linux pop mail directadmin command

so to transfer email from one DA box to another:
scp -r 64.254.200.10:/etc/virtual/rubesreadymeals.com/* /etc/virtual/rubesreadymeals.com

scp -r 64.254.200.10:/var/spool/virtual/rubesreadymeals.com/* /var/spool/virtual/rubesreadymeals.com

Mysql directories and move info

It is no fun when a linux shared hosting server crashes. You have to move the web files, email, and any mysql databases the users websites are running on, not to mention DNS info. So get some mountain dew and lets get started:

Mysql important directories:
The databases are all here: /var/lib/mysql

Grep for the mysql username and password in:
Joomla - configuration.php
Drupal - settings

Directadmin info is here: /usr/local/directadmin

Wednesday, August 12, 2009

tar help (zip up a linux dir and all files and subdirs)

use this to zip up linux dirs, files, folders, subdirs, etc.

tar -cvzpffilename.gz {source dir or files wildcard}

Example:
tar -cvzpfpublic_html_backup_08122009_plinkgolf.gz public_html

where:
-f - whatever follows the f is the filename, so public_html_backup_08122009_plinkgolf.gz is the tarball/zip file name in this case.
-v indicates verbose listing of command output.
-c indicates create a new tar ball file.
-z indicates use gzip.
-p indicates preserve all permissions of underlying files/dirs being zipped.
public_html - is the name of the top level folder I am zipping including all its subfolders and files underneath it

Have a nice day!

Oops - almost forgot, to explode/unzip the zip file in the current directory, just type:

tar -xvf nameofzipfile.gz

Friday, July 03, 2009

Find out who is logged on as root (or any other user)

So I want our support team to get an email when someone logs on as root or su to root on our servers. So I saw this:
Want to be notified instantly when someone logs into your server as root? No problem, check out this nice tutorial on email notification for root logins. Keeping track of who logs into your server and when is very important, especially when you're dealing with the super user account. We recommend that you use an email address not hosted on the server your sending the alert from.

So lets get started!

1. Login to your server and su to root, I know the irony!

2. cd /root

3. pico .bashrc

4. Scroll to the end of the file then add the following:
echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

Replace YourServerName with the handle for your actual server
Replace you@yourdomain.com with your actual email address

5. Crtl + X then Y

Now logout of SSH, close the connection and log back in! You should receive an email address of the root login alert a few minutes afterwards.

But I changed to this:
Edit root (or whatever user you wanted) .bash_profile

echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `netstat | grep ssh`" you@yourdomain.com

Replace YourServerName with the handle for your actual server
Replace you@yourdomain.com with your actual email address

This netstat gives you all users connected to your box via ssh at that time, not just the specific user who just sshed in.

Example Output (user SSH sessions from my home laptop ip of 70.131.105.251:
tcp 0 0 ls3.harmonicwebhosting.:ssh adsl-70-131-105-251.d:61852
ESTABLISHED
tcp 0 220 ls3.harmonicwebhosting.:ssh adsl-70-131-105-251.d:63195
ESTABLISHED

ALERT - Root Shell Access on (ls3.harmonicwebhosting.com-64.254.200.10): Fri Jul 3
11:37:51 CDT 2009

Wednesday, July 01, 2009

DirectAdmin DNS issue same shared Linux server-cannot send email to other domain hosted on same server

So we are running Direct Admin on one of our shared linux web hosting servers and ran into a problem where one domain had switched email services to google apps (another mail server not hosted on the Direct Admin shared mail server).

So all other domains on that server could not send email to that domain since they thought the local server was still serving mail even though they changed the MX records to google servers.

Long story short to fix this go to:
Click on the domain in question, Click on Modify DNS Records, Click on Modify MX records, then uncheck the local mail server box as follows:
Local Mail Server
Use this server to handle my emails.
If not, change the MX record and uncheck this option
*Note: Making modifications to the MX records can potentially disable all of your email accounts from recieving mail.
ONLY make modifications if you know what you are doing.
Make sure to include the period at the end of the domain. (eg: mail.domain.com. )

Thursday, March 05, 2009

Using the SCP command (Linux)

20.3.2. Using the scp Command

The scp command can be used to transfer files between machines over a secure, encrypted connection. It is similar to rcp.

The general syntax to transfer a local file to a remote system is as follows:

scp username@tohostname: 

The  specifies the source including path to the file, such as /var/log/maillog. The  specifies the destination, which can be a new filename such as /tmp/hostname-maillog. For the remote system, if you do not have a preceding /, the path will be relative to the home directory of username, typically /home/username/.

To transfer the local file shadowman to the home directory of your account on penguin.example.net, type the following at a shell prompt (replace username with your username):

 scp shadowman username@penguin.example.net:shadowman  

This will transfer the local file shadowman to /home/username/shadowman on penguin.example.net. Alternately, you can leave off the final shadowman in the scp command.

The general syntax to transfer a remote file to the local system is as follows:

scp username@tohostname: 

The  specifies the source including path, and  specifies the destination including path.

Multiple files can be specified as the source files. For example, to transfer the contents of the directory downloads/ to an existing directory called uploads/ on the remote machine penguin.example.net, type the following at a shell prompt:

 scp downloads/* username@penguin.example.net:uploads

Good Linux find command and Joomla Footer

Here is the linux command I used and the file location in joomla to edit the footer:

From the public_html folder of the domain:

find ./ -type f -exec grep -H copyright '{}' +

 

The footer file you can edit to change the Joomla 1.5 standard footer is here:

/home/aheumann/domains/theheumannmarketreview.com/public_html/language/en-GB/en-GB.mod_footer.ini

Reset Root Password from console or root single user mode

So we have disabled root ssh to our linux boxes now.  But to reset the root password we need to login as a approved ssh user (/etc/ssh/sshd_conf AllowUsers bacuff for example) then su root
Enter old root password
then passwd change to new root password

or - if you have no valid ssh users (bad but we foudn ourselves in this case today on our important shared web and mail server):
I'd first see if they can get in with the root pw first on the console, if that does not work, you would reboot, and when you get to the grub boot loader, you press e for edit, the second entry, you modify, and you put 'single' at the end of that line, then boot that up, it will drop you into root single user mode, and they can reset the password