File atime is the last accessed time of the file, in PHP, you can get the last accessed time of any file by:
$last = fileatime('anyfile');
File ctime may be a little misleading in nature as many would think it as the creation time of the file, but actually it’s the meta data such as the ownership or permissions change time of the file in addition to content modification. To get the ctime of a file in PHP:
$last = filectime('anyfile');
wc -l foo.txt
And the system returns:
Meaning foo.txt has 12 lines.
To count unique lines a file has:
sort -u foo.txt | wc -l
Which will simply exclude all extra lines that are identical.
To check whether you are one of the victims that are dwelling on oversold web hosting servers, you need to have SSH access to your server. Now perform the following commands:
cat /proc/cpuinfo | grep processor | wc -l
Which will usually return the number of the CPUs of the current server:
Then, display the server load by
Which outputs a single line of information concerning the server load and how it is doing its jobs:
08:44:12 up 11:09, 2 users, load average: 1.91, 2.37, 2.09
Now you’ve got the data you need to calculate the server oversellingness.
Lost in Linux and shell commanding?
There are a number of ways to get information about a particular Linux command. Chances are you are using bash shell which is currently the most popular shell of all types of Linux distributions, therefore in a sense, what you mean by Linux commands are bash commands.
So what are the ways to know more about a particular bash / Linux command?
ls is probably the most frequently used linux command for listing files under a particular directory, to know more about the command ls, type:
To exit and quit vi text editor, you need to type:
To save the changes you have made and quit:
To discard the changes and quit without saving the file:
What? You have no idea what I’m talking about?!
There’s a detailed step by step tutorial for turning your web host into a socks5 proxy server.
Basically, you use PuTTY to utilize the SSH connection to the web hosting server to be an alternative transport of all traffic between your personal computer browser (or any other web clients such as FTP programs or IM) and the destination site (such as facebook or myspace). Of course, all the transfer will be billed in your web hosting subscription.
Not bad at all, if you have some large chunks of extraly available transfer to spare from your current web hosting plan. It’s simply the most stable and usable proxy server you can get and make for yourself, much better than the servers in all the un*available* proxy servers lists you can find online.
Yes you can log into phpmyadmin, backup your database by simply using Export and recover it by using Import. However all lamp servers come with a max upload file size, limited by the smaller of upload_max_filesize and post_max_size while also restricted by php.ini configurations such as memory_limit and max_input_time. What if you’ve got a huge database of hundreds of thousands of records taking up a few dozens of megabytes or even more?
Use MySQL command line to fulfill the same task.
mysqldump -h localhost -u username -p dbname > sqlfile.sql
After dumping it as a SQL text file, you may want to first zip it using the following command:
tar zcf sqlfile.sql.tar.gz sqlfile.sql
And download it to your local computer to be kept safe. When an emergency occurs, upload sqlfile.sql.tar.gz to your web server and unzip it:
tar zxf sqlfile.sql.tar.gz
Now that you have sqlfile.sql, you may proceed to restore it back into database, using the command below.
mysql -h localhost -u username -p dbname < sqlfile.sql
Beware of the less than / greater than mark that’s representing operation directions.
Change localhost to your own mysql server address, username to your own mysql account username and dbname to the name of the database to be backed up or recovered. Straight enough.
Also notice that MySQL user password is not specified in the command line but you will be prompted to enter it after hitting enter.
Just perform this command under the directory:
find . -type f | wc -l
and you will get the total number of files under it (recursively). Simply copy and paste that to do the trick.
Or if you just need to count the files directly under the current directory:
ls -f | wc -l
Which is a lot faster than the previous solution.
This should also work on all *nix OS.