Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Monday, August 17, 2020

Monitoring coreutils basic operation progress, with progress app

While copying or moving stuff across locations in my computer, using terminal, most of the time I want to have a progress reporting of how much has been copied or moved. This can be easily achieved using a neat little tool called progress. To use it, you have to install it first.

To install progress

$ sudo apt install progress -y


Start you coreutils basic operation (cp, mv, dd, tar, gzip/gunzip, cat, etc.)

$ cp CentOS-8.1.1911-x86_64-dvd1.iso /data/


Monitor the progress using progress. Just run progress:

$ progress


To continuously see the progress, just use the -m option. It will update regularly, and speed and estimated remaining time will be shown 

$ progress -m




Thursday, January 22, 2015

How to manage files whose name starting with hyphen (-), or double hyphen (--)

There are a few ways you can manage these kind of files, the normal way won't work, since this filename will be treated as options for almost all commands. Please see below on the method to manage these files:

Let's say the file name is -p, and you are trying to delete it,  the usual error is, since the -p is being treated as the flag for command rm, rather than a file name:

$ rm -p
rm: invalid option -- 'p'
Try 'rm ./-p' to remove the file ‘-p’.
Try 'rm --help' for more information.


So, the correct way to manage this file is:

To list:

$ ls ./-p
$ ls -- -p
$ find . -maxdepth 1 -iname "-p"


To delete:
$ rm -- -p
$ rm ./-p
$ find . -maxdepth 1 -iname "-p" -delete


To create:
$ touch ./-p


Basically, the ./ can be used with any command, while the " -- " have been tested working with ls and rm.

Hope this is helpful, thanks to stackexchange for this useful tips.

Saturday, November 14, 2009

Creating specific sized file

To create a specific sized file, dd command can be used. Example below will create a file named output with 10M size:


$ dd if=/dev/zero of=output bs=1M count=10
where bs is block size, and count is number of blocks to be created

The output:

$ ls -lh output
-rw-r--r-- 1 user user 10M 2009-11-14 06:21 output

Friday, November 13, 2009

Splitting big files

To split big files, split command can be used. Below is command used to split 400MB file named bigfile into 100MB chunk files named smallfile0*


$ split -b 100M -d --verbose bigfile smallfile
creating file 'smallfile00'
creating file 'smallfile01'
creating file 'smallfile02'
creating file 'smallfile03'
where -b is for byte size, -d is for numeric suffixes and smallfile is the prefix to be used

The output is:
$ ls
bigfile smallfile00 smallfile01 smallfile02 smallfile03

To recover back the splitted files into a file named newbigfile:
$ cat smallfile0* > newbigfile


Thursday, August 6, 2009

Mounting Windows shared folder on linux

Mounting windows shared folder on linux is very easy provided you know the ip of the windows machine, the name of the folder that is being shared, the username and password of the windows machine. As far as I know, there are 2 ways you can mount your windows shared folder on your linux machine.

The first way:

For gnome user, type Ctrl+F2, and type smb://windows_machine_ip/shared_folder_name. For example, see below picture


You can access the folder from Places


The second way:

Using command line;

sudo mount -t cifs //windows_machine_ip/shared_folder_name /directory_to_mount -o username=username,password=userpassword

example for mounting a shared folder named MP3 on 192.168.1.110 using windows username usin and password 123456 to /home/user/mp3:

$ sudo mount -t cifs //192.168.1.110/MP3 /home/user/mp3 -o username=usin,password=123456

Your shared folder now can be accessed from /home/user/mp3


That's all friends :)