Use grep
example, look for the text hsbc in the /srv/www/ location
# grep -r -l "hsbc" /srv/www/
My personal Linux notes, a work in progress, shared online with the world. From intro to pro Linux Administration.
Wednesday, May 1, 2013
Apache web service wont start after restart, apache2 error "Address already in use"
If you stopped or restarted the apache2 server service and it failed to start this article should help.
You might type the command: rcapache2 start
You might get an error like this:
Starting httpd2 (prefork) (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
startproc: exit status of parent of /usr/sbin/httpd2-prefork: 1 ... failed
Try this:
Run each of these commands
for i in `ps auwx | grep -i nobody | awk {'print $2'}`; do kill -9 $i; done
for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
then run
service httpd restart
or run
rcapache2 start
Until next time
thanks
P.S. like anything else on this blog, the instructions are 'as is' and use art your own risk.
You might type the command: rcapache2 start
You might get an error like this:
Starting httpd2 (prefork) (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
startproc: exit status of parent of /usr/sbin/httpd2-prefork: 1 ... failed
Try this:
Run each of these commands
for i in `ps auwx | grep -i nobody | awk {'print $2'}`; do kill -9 $i; done
for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
then run
service httpd restart
or run
rcapache2 start
Until next time
thanks
P.S. like anything else on this blog, the instructions are 'as is' and use art your own risk.
Wednesday, March 6, 2013
Mysql ODBC connection to Linux Mysql database
If you have a database user that needs and ODBC connection to a mysql database, you create a user name and password, then before they can connect you need to add that user's computer IP address to linux to enable or allow access. By default, MySQL does not allow remote clients to connect to the MySQL database and your user is likely connecting remotely.
Use this code:
use mysql
GRANT ALL ON *.* to USERNAME @'10.30.1.2' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Replace the USERNAME and PASSWORD with your actual values.
Also, update firewall rules to make sure port# 3306 is open on the server that is running the mysql database.
remember, first you need to login to mysql
$ mysql -u root -p Enter password:
Labels:
connect,
database user,
MySQL,
ODBC,
remote connect,
user
Tuesday, February 19, 2013
Find the Size of Directory in Suse Linux
Try these
du -h ./
For the most part this works. If you have spaces in file/directory
names than you may get some errors, but I'm sure you can work around
those if needed:
ls -1drt *| xargs du -h --summarize
You could also try
du -hc --max-depth=1
This will give you all the directories in the current directory, and a total at the bottom. Play with the --max-depth to dig down further in the structure and get more fine-grained results.
You can run this with a pipe to grep "G" to do a quick search of folders that are large enough to be measured in gigabytes. It will pull any directories with a capital G in them, but there aren't many of those so it works for me.
du -hc --max-depth=1 | grep "G"
du -h ./
For the most part this works. If you have spaces in file/directory
names than you may get some errors, but I'm sure you can work around
those if needed:
ls -1drt *| xargs du -h --summarize
You could also try
du -hc --max-depth=1
This will give you all the directories in the current directory, and a total at the bottom. Play with the --max-depth to dig down further in the structure and get more fine-grained results.
You can run this with a pipe to grep "G" to do a quick search of folders that are large enough to be measured in gigabytes. It will pull any directories with a capital G in them, but there aren't many of those so it works for me.
du -hc --max-depth=1 | grep "G"
Friday, February 15, 2013
Where's the php.ini file
/etc/php.ini
Or here:
/etc/php/php.ini
/etc/php5/php.ini
Or here:
/usr/bin/php5/bin/php.ini
Anyway, you can always find any file named php.ini in this manner
find / -name php.ini
The simplest yet most powerful usage of the renowned find command. By its help I was able to locate the php.ini on my Ubuntu 9.04 Apache2 and PHP5:
/etc/php5/apache2/php.iniThursday, February 14, 2013
Show Processes Running on Linux, RAM process usage
ps command
Type the following ps command to display all running process:
Where,
# ps aux | lessWhere,
- -A: select all processes
- a: select all processes on a terminal, including those of other users
- x: select processes without controlling ttys
Task: see every process on the system
# ps -A
# ps -eTask: See every process except those running as root
# ps -U root -u root -NTask: See process run by user vivek
# ps -u vivekTask: top command
The top program provides a dynamic real-time view of a running system. Type the top at command prompt:
# topFree Disk Space / Disk usage on Linux
Q. How do I check free disk space in Linux or UNIX operating system? I've migrated from Windows NT to Linux and looking forward to get more information about free disk space.
A. Both Linux and UNIX offers two commands for checking out free disk space:
(a) df command : Report file system disk space usage
(b) du command : Estimate file space usage
df command examples - to check free disk space
Type df -h or df -k to list free disk space:
OR
$ df -hOR
$ df -klinuxServer:/ # df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 109038804 82892008 20610028 81% /
udev 3864264 92 3864172 1% /dev
/dev/sda3 10079572 5955024 3612484 63% /home
or you can run this command to get the file sizes at depth 1
# du -hc --max-depth=1
Thanks
Labels:
df,
disk space,
disk usage,
du,
free disk space,
space
Subscribe to:
Posts (Atom)