Tech geek. Life geek.

Tag: command (Page 1 of 2)

Force IPv4 when using APT command in Ubuntu

Sometimes you may want to disable IPv6 when using apt update command or some other apt operation.

If you want to use IPv4 in one command, just run following:

$ sudo apt -o Acquire::ForceIPv4=true update

If you want to force to use IPv4 for all apt operations, add a new file under /etc/apt/apt.conf.d/

$ sudo nano /etc/apt/apt.conf.d/99force-ipv4

Then add a line:

Acquire::ForceIPv4 "true";

If you want to disable IPv4, change the IPv4 to IPv6.

How to check the disk usage of your VPS

The df utility displays the disk space usage on all mounted filesystem.

The -T option prints the filesystem type as well. By default, df measures the size in 1K blocks, which could be a little difficult for a desktop user to decipher. Use the -h option to get the more understandable output:

davidyin@localhost:~$ df -h -T
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  463M     0  463M   0% /dev
tmpfs          tmpfs      99M  7.0M   92M   8% /run
/dev/sda       ext4       25G   12G   12G  51% /
tmpfs          tmpfs     493M     0  493M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     493M     0  493M   0% /sys/fs/cgroup
tmpfs          tmpfs      99M     0   99M   0% /run/user/1000

The VPS system will be problemed when the disk is used 100% full.

So to make sure the disk usage in the health range is very important. Clean the files when it is growing too fast or close to 85% or 90%.

Look at the log files. For example, web site error log, web site access log, security log files.

How to know the disk usage of your VPS

It is a simple task and a very common task for a VPS user. You have a VPS, and want to know the disk usage of your data and system. You are also want to know which folder takes the biggest disk space.

The command is du



du takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is used. The SUS mandates for du the following options:

-a, display an entry for each file (and not directory) contained in the current directory
-c, display a grand total of the disk usage found by the other arguments
-d #, the depth at which summing should occur. -d 0 sums at the current level, -d 1 sums at the subdirectory, -d 2 at sub-subdirectories, etc.
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each file
-x, only traverse files and directories on the device on which the pathname argument is specified.


Above command usage method retrieved from Wikipedia.

Here is what I entered to get the result I want.



Continue reading

Delete files recursively

The task is to delete files from the folder and sub-folders, maybe sub-sub-folder.
Say I want to delete .htaccess from every folder, but keep all others no-touch.
It is hard to go into each folder and delete the file. It takes time and also very easy to miss some folders.
There is one command in Linux. Great tool for it.
One line to do the job.

Continue reading

How to close Firefox windows without prompt

I have a batch file, to run the command and want to close it automatically.
Basically, I can use javascript to close it.
But it is always prompt that ask for Confirmation.
Actually I just want it run by schedule and close itself after finishing.
So, I use the Google BB (Big Buddha) to search it.
The final answer and only one answer is below.
The reason why the script is not working, is that Window is not opened by javascript. So it can not be closed by javascript automatically. It is simply concept. And the solution is also simply.

Continue reading

Is your Linux 32bits or 64bits

Some times you need to find out what version is your Linux OS. Just like when I need to download a module, I have to find out which one is right for my OS. Then I can download 32bit, or 64bit package.
The most common way to find your Linux installation is enter the following shell command.

uname -a


uname -m

i386 => 32bits, x86_64 => 64bits

Continue reading

Large mySQL database transferring

To transfer the the large mySQL database, you need to learn how to use command to do it.
Large, means the database is bigger than 8 MB after compressing.
phpmyadmin, is a wonderful web tool for mySQL. But the limitation of upload is 8 MB. If the backup file is larger than it, you can not upload it, of course can not import it.
The platform I am working is Linux, Centos. It is ssh command environment.
1) Backup, export all tables of one database into one file.

mysqldump -u root -p databasename | gzip > backup.sql.tar.gz

I use this command to backup my forum database. The result is gzip file, means after compressing. I have a database is above 500MB. The gz file is about 125MB.
When I have the gz file, I can download it to my PC, or put it on other server for transferring.

Continue reading

« Older posts

© 2020 David Yin's Blog

Theme by Anders NorenUp ↑