Useful linux commands

From EuSurplusWiki
Jump to: navigation, search


Disk clone

To clone a hard disk, use the dd command with the following syntax in a command line:

sudo dd if=/dev/sdb of=/dev/sdc bs=4096 conv=notrunc,noerror,sync

where if is input, source and of is output, target. This command should be issued to hard drives that are not in use. For example, use a live PEN from which a terminal can be used.

Folder share

To share a folder in linux the most versatile way is using samba. Therefor please install the samba packages using apt-get install command.

Install the samba server: sudo apt-get install samba

Install the samba client: sudo apt-get install smbclient


After installing samba, edit the file named smb.conf generally located in /etc/samba/

The following changes are to add a folder that is shared without security and can be read/write by everyone.

Step 1

Search for the work "security". If the security setting is preceded with the symbol #, remove it and change your file so that it contains the following 2 extra lines:

security = user

map to guest = bad user

guest account = your_user_name

where your_user_name should be equal to a existing user name of the machine running samba. This means that all the changes made on the folder remotely will be assigned to the user name indicated on this setting.

Step 2

Add the folder to be shared. In the example below I am sharing a folder named "work" that will also appear on the network as "work". The setting with [] is the network name. The following lines can be added anywhere on the file, but normally are added on the bottom of the file.

[work]

path = /home/my_machine/work

available = yes

browsable = yes

public = yes

writable = yes

Step 3

Save and restart samba:

/etc/init.d/samba restart

or, if you are using systemd

/usr/sbin/service smbd restart


Tool table limit (257 instead of 56)

By default the tool limit of linuxcnc is 56 tools. This is normally to low (after all we are not working with a >10 year controller). To solve this two changes must be made in the source code as described below:

linuxcnc.nml

The file linuxcnc.nml is located at:

"your linuxcnc-dev"/configs/common/linuxcnc.nml

Two changes should be made:

Replace the value 16384 of line number 10:

B emcStatus SHMEM localhost 16384 0 0 2 16 1002 TCP=5005 xdr

to 33792

B emcStatus SHMEM localhost 33792 0 0 2 16 1002 TCP=5005 xdr


and replace the value 8192 of line number 15:

B toolSts SHMEM localhost 8192 0 0 5 16 1005 TCP=5005 xdr

to 33792

B toolSts SHMEM localhost 33792 0 0 5 16 1005 TCP=5005 xdr


emctool.h

The file emctool.h is located at:

"your linuxcnc-dev"/src/emc/nml_intf/emctool.h

One change should be made:

Replace the value 56 of line number 23:

define CANON_POCKETS_MAX 56

to 257

define CANON_POCKETS_MAX 257


Compile and have fun with more tools!