Find and order all files by size, save the result to a text file on a Linux system
du -k | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1 >= 1024) {
$1 = $1 / 1024;
u += 1
}
$1 = sprintf("%.1f %s", $1, Units[u]);
print $0;
}
' > result_list_ordered.txt
My personal Linux notes, a work in progress, shared online with the world. From intro to pro Linux Administration.
Wednesday, May 1, 2013
Find files by modification date, within a modified by date range on Linux
Find files modified within a date range
Use these commands
touch --date "2013-04-29" /tmp/start
touch --date "2013-05-1" /tmp/end
find -type f -newer /tmp/start -not -newer /tmp/end
Use these commands
touch --date "2013-04-29" /tmp/start
touch --date "2013-05-1" /tmp/end
find -type f -newer /tmp/start -not -newer /tmp/end
Labels:
Date,
Date Range,
Find,
Modified Date,
Search,
touch
Search or find all users on a Linux system
List all users on a Linux OS
Try one of these:
# cut -d: -f1 /etc/passwd
# cat /etc/passwd | cut -d ":" -f1
Got other ideas on how to do this? please leave a comment
Thanks!
Try one of these:
# cut -d: -f1 /etc/passwd
# cat /etc/passwd | cut -d ":" -f1
Got other ideas on how to do this? please leave a comment
Thanks!
Search files for a string in linux
Use grep
example, look for the text hsbc in the /srv/www/ location
# grep -r -l "hsbc" /srv/www/
example, look for the text hsbc in the /srv/www/ location
# grep -r -l "hsbc" /srv/www/
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.
Subscribe to:
Posts (Atom)