0% found this document useful (0 votes)
21 views

Unix Commands

The document provides instructions for various basic UNIX commands for file management, editing, copying files between UNIX and DOS, and creating a boot disk for XNC. It explains commands like ls, cd, cp, cat, rm, tar, dosread, vi, and mkfs. It also summarizes how to view file properties with ls -l, use a boot disk to boot the system if it fails to start regularly, and change file ownership with chown.

Uploaded by

ANDREI HENDRIC
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Unix Commands

The document provides instructions for various basic UNIX commands for file management, editing, copying files between UNIX and DOS, and creating a boot disk for XNC. It explains commands like ls, cd, cp, cat, rm, tar, dosread, vi, and mkfs. It also summarizes how to view file properties with ls -l, use a boot disk to boot the system if it fails to start regularly, and change file ownership with chown.

Uploaded by

ANDREI HENDRIC
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1

unix commands

UNIX COMMANDS
UNIX COMMANDS.............................................................................................. 2
Basic commands of the vi (edito di Unix)...............................................................................2
Creating a boot disk for XNC................................................................................................... 3
Using the Boot disk................................................................................................................. 4
Unix file properties.................................................................................................................. 4
Copy to disk............................................................................................................................ 5
Linked files.............................................................................................................................. 5
Finding a file inside the machine backup disks.......................................................................6
Copy and check disk commands <cpdisk - verarc>...............................................................6
Commands for shifting a file from Unix--->Dos......................................................................7
Creating zipped files (.tgz)...................................................................................................... 7
Creating machine backup files................................................................................................8
Creating the disk d_xnc (doc in Italian/English)......................................................................8
Istruction fsck for “cleaning” the file systems........................................................................8
Command to search a file in xnc............................................................................................ 8
Removing the random magazine from the graphics...............................................................8
Istructions for screen saver timer...........................................................................................9
Changing the time on XNC.................................................................................................... 10
Entering X-terminal............................................................................................................... 10
If the NC locks at the start up giving the message File or directory doesn’t exist................10
Length of the XNC program names.......................................................................................10
Display card status............................................................................................................... 10
Checking if the Compiled PLC exists (previous version 1.2.0.0)..........................................11
Disk copy and check commands <cpdisk - verarc>.............................................................11
2
unix commands

UNIX COMMANDS
cd [pathname] changes the working directory

ls [opzioni] [dir] displays the content of a directory with the following options:
-a hidden files are displayed too
-l for each file is displayed information such as: the type (file “-”,
directory “d”), the permissions and the owner.
-F displays names of files marked with * if they are executable files,
with / if they are directories, or with @ if they are links to other files.

mkdir [dir] creates a directory.

rmdir [dir] deletes a directory (empty!!!).

pwd displays the Path of the current directory.

ps -ax displays the list of running processes with the following information:
PID (identification number) of the process, number of the terminal on
which the process is launched, process status, time of CPU use and command name
associated to the process.

kill [Process PID] ends the execution of the process specified by the PID number.

more displays in consecutive portions (usually used together with ls


when the list of files is too long to be contained in a single screen-shot:
ls|more).

cp file1 file2 copies the content of file1 in file2.

cat file displays the file content.

rm [opzioni] file deletes files with the following options:


-i delete confirmation is displayed before deleting the file
-f removes the file even if write-protected
-r allows deleting directories and files there contained.

ln -s file1 file2 creates a link from file2 to file1.

mv file1 file2 changes a file name file1 in file2; if file2 already exists, it is deleted.

tar [opzioni] file allows copying files from/to UNIX floppy disks. The options are:
cv to copy a file from hard disk to floppy
xv to copy a file from floppy to hard disk
tv to display the content of the floppy.

dosread [opzioni] /dev/fd0 file DOS > file UNIX allows copying a file from DOS floppy to
hard disk. Use option -a if the file is a text file.

doswrite [opzioni] /dev/fd0 file DOS < file UNIX allows copying a file from the hard disk to
the DOS floppy. The same rule of dosread for option –a applies

dosdir /dev/fd0 to see the content of a DOS floppy

Basic commands of the vi (edito di Unix)


3
unix commands
vi filename Open or creates a file
view filename Opens the file as read-only
i Inserts a character on the left of the cursor
I Inserts a character on the left of the cursor at the beginning of the line
x Deletes the character
dd Deletes the line
/stringa/ Finds the string
zz Saves and exits the vi
:q! Exits the vi without saving

NB: to shift command press the key [ESC]

Creating a boot disk for XNC

From X-Terminal enter the system as SU

su (Enter)

insert a 1.44MB floppy and proceed as follows:

fmtflop /dev/rfd0 Formatting the floppy in Unix format

mkfs /dev/fd0 creates file system on floppy

mount /dev/fd0 /mnt loads the file system on floppy

cd /mnt opens drive A

cp /{preboot, lynx.os,init} . copies the three files into the current directory
mnt

. /CYGNUS.bash enables the use of the command strip

cd /tmp

cp /bin/{bash,reboot,mount,umount,fsck,tar,mkpart} . copies the files into


the directory tmp of drive C

strip {bash,reboot,mount,umount,fsck,tar,mkpart} zips the files

cd /mnt goes back to drive A

mkdir bin dev etc mnt creates directories on floppy

cd /tmp

cp {bash,reboot,mount,umount,fsck,tar,mkpart} /mnt/bin copies files to drive A

cd /etc

cp {passwd,group,tconfig,termcap,ttys,starttab,nodetab} /mnt/etc copies files


to drive A

cd /mnt/dev
4
unix commands

mknod -a restores the physical devices on drive A

cd /mnt

makeboot ./preboot makes the floppy bootable

cd /

umount /mnt removes the file system from the floppy


The creation of the Boot disk is now complete.

Using the Boot disk

The boot disk is used when the control does not start regularly due to system errors or
because some functions of the system have been deleted or tampered.

Use procedure:

Insert the Boot disk and start the control; once loaded, the terminal will display the
following message:
bash#
run the commands in the following sequence:
fsck /dev/hd0a (in case of errors, use the same command until they disappear)
fsck /dev/hd0b
mount /dev/hd0a /mnt
PATH=/mnt/bin

Now, the commands contained in the directory bin of the hd are available.
Ex: ls (directory content) rm (remove file) etc.

For using the vi, edit the command

TERM=vt100

Unix file properties

To see the properties of a file, you must add -l to the command ls


 ls -l (file name) or without name the entire directory is listed
10 symbols will be displayed as follows:
-rwxr--r-- 1 xnc
- r w x r w x r w x
|----------| |-----------------------------------| |-----------------------------------|
|-----------------------------------|
TYPE OWNER GROUP OTHERS
FILE

 FILE TYPE can have the following value:


- ----> normal file
d ---> directory
l ---> link
 OWNER is the file owner
 GROUP is the owner group
 OTHERS are the users outside of the owner group
 r read-only file
 w changeable file
 x executable file
properties not set are referred to with -
 xnc shows the file owner
with ls -l |more you can scroll the list as dir/p of DOS
5
unix commands

You can change the file owner with the command chown, but only the owner or the super
user can do it:
on
chown (new owner) (file name)
You can also change the properties of the file with the command chmode :
on
chmod 731 (file name)
7 sets all three 3 bits of the owner
3 sets the first and second bit of the group
1 sets the first bit of the others
or:
on
chmod (u)(g)(o)+(r)(w)(x)
the first letter shows where to change, + to add and – to remove, the second letter shows
what to change.
The command whoami shows who I am at the moment:
 type
whoami
 Unix answers
root

Copy to disk
 The command tar allows carrying out operations on the floppy

- tar cv (file name) from H.D. to floppy. All that was on the floppy is deleted.

- tar rv (file name) the files are added to the floppy, and the old content of the
floppy is maintained.

- tar xv (file name) from floppy to H.D. , all the floppy is copied if no file is
specified.

- tar tv shows the floppy content.

 The command gnutar allows executing operations on the floppy with zipped
files.

- gnutar -ztvf (file name) shows the content of a zipped file on the H.D.

- gnutar -zPxtvf (archive name) (list of files to extract from the archive)
extract and unzips the files required from the zipped file,
and installs them in the origin paths.

 The command cat allows copying a floppy to another floppy. You must first copy
the floppy to HD.

- cat /dev/fd0 > (file name) copies the floppy content to the HD saves it as file.

- cat (nome file su HD) > /dev/fd0


copies the file previously copied from the other floppy.

Linked files

With Unix you can link the files, that is to say, or can refer to a pointer file which takes up
few bytes, which launches the actual file:
The command to link the files is :
 ln -s (name of the file to point) (name of pointer file)
6
unix commands

Finding a file inside the machine backup disks


You can extract any file from the backup disks and enter them directly into the proper
directory of the hard disk with the following command:

gnutar^xOMf^/dev/fd0^|^gnutar^-zxPvf^-^(directory + first file name)^


(directory + second file name)^(directory + third file name ...)^etc.

^ insert a blank space


| shift + \ (pipe)
P extract the files from the floppy and puts them in the correct directory of the hard
disk

Example of extraction of the 2 files making up the PLC from the backup and their automatic
positioning in the correct directories of the hard disk :

gnutar^xOMf^/dev/fd0^|^gnutar^-zxPvf^-^/home/xnc/bin/isaker^
/home/xnc/bin/plc-objs/prog.oo

where:
/home/xnc/bin is the path of the first file to be extracted
/isaker is the name of the first file to be extracted
/home/xnc/bin/plc-objs is the path of the second file to be extracted
/prog.oo is the name of the second program to be extracted
insert the 4 disks (volume 1 2 3 4)

Note: to find a file in the ’hard disk:

find^/^-name^nomefile^-print (^=space)

Copy and check disk commands <cpdisk - verarc>

With the updating disks, there is another disk with the files CPDISK and VERARC.
use these files to

copy disks
check disks

You have to first install the files to the hard disk as follows:
enter X-terminal
type SU (superuser) and press Enter
insert disk CPDISK - VERARC
type INS and press Enter and follow the instructions of the NC.

Once the installation is complete, you can use these files every time you must do a copy of
a disk (non-UNIX disks also):
just type SU Enter, CPDISK enter and follow the instructions of the NC.
with the file VERARC (check archive) you can check the integrity of the disk.
7
unix commands
Check that there are no strange errors or messages, but only the names of copied files.

Commands for shifting a file from Unix--->Dos

For zipped files (.tgz) use the following commands:

XNC ------> DOS


doswrite^/dev/fd0^ target file name ^<^ source file name

DOS ------> XNC


dosread^/dev/fd0/^source file name ^>^target file name

In case of files not zipped use the parameter -a


doswrite^-a....
dosread^-a.....

^ insert a blank space

NOTE:
You can also use DOS commands

mwrite file name “A:\.”

Mread “A:\*.*” .
(the full stop means you want to maintain the same name)

Creating zipped files (.tgz)

Create a file files.aux to specify what file(s) must be zipped.

 open X-terminal
 type su
 type vi files.aux
a unix file will be opened, in which you must indicate what files must be zipped into .tgz
 type for example \home\d_xnc to zip the directory d_xnc
 save the file with :x
 type gendsk (creates the file and puts it into the current directory of the hard disk)
at the end, you will be asked if you want a copy of the file of the disk.

NOTE:
When unzipping, a TGZ disk will download the files in the same directories in which they
have been zipped. If these directories do not exist anymore, it will create them
automatically.
8
unix commands

Creating machine backup files

To create a backup copy of the machine:


 open X-terminal
 type su
 type genbackup
 the machine serial number will be required for filing
 the disks will be required

Creating the disk d_xnc (doc in Italian/English)


(Saving the Machine Data files to a Safety Disk)

This procedure is recommended:


if the machine is updated
at the end of the installation
or if its features have been modified
or simply you do not have a safety disk “D_XNC” with the copy of all files relating to the
machine configuration and those created by the client (Machine Data, programs,
subprograms, fixed cycles, schedules, icons, figures, PLC user tables).

Enter DISK MANAGER by pressing F12, Disk Manager, Enter


Format a 1440Kb disk in Unix format (in some cases one disk could not be enough; we
suggest that you format more disks).
Select in the “SERVIZI” menu the item “Compresso”.
Select HD as source and Drive A as target
Select the icon “back up totale”
select the icon copia.

The NC will now create a disk “D_XNC” of the same type as that supplied with the machine,
but updated with the new data.

The files of the disk thus created, unlike the disk supplied with the machine, can be easily
found from the environment DISK MANAGER.

Istruction fsck for “cleaning” the file systems

The command fsck^/dev/hd0a controls the file system and removes temporary files.
The command operates using the directory lost+found located in the main directory (type
cd / to reach it) .
Attention:
This command is automatically launched whenever the machine is started up, but should
the directory loast+found be missing, the command may be never executed, thus locking
the system (after some time, any writing on the hard disk is impossible, giving the error
device is full). In this case, try deleting some files and type the command again.

Command to search a file in xnc

You can search a file among the directories located on the XNC with the following
command:

 find^/^-name^(nome del file)^-print

Removing the random magazine from the graphics

If the icon of the RANDOM magazine is displayed, you just have to enter the machine data,
magazine, and delete all the lines of magazine that are not actually used.
If in the machine data there are only the lines actually used for the magazines, the random
icon will disappear automatically.
9
unix commands
Istructions for screen saver timer

To change delay time:


 open an x-term and type :
su (enter)
 type :
vi /home/xnc/.xinitrc
 move the cursor on the 5th line where is written : xset s noblank and type the letter o
 a new empty line will appear under the current one, type:
xset s 100 ( where 100 is the delay seconds)
or type
xset s off (where off will disable the screen saver)
 press the ESC button and then the : button
 cursor will move to the last line of the monitor
 type x (enter)
 reboot
An other updated solution to work with xmeditor and with version 1200
To change delay time:
 open an x-term and type :
su (enter)
 type :
xmeditor& (enter)
this is an Edit-text program. With this program, you can modify the text of any file. We
need to change this file: /home/xnc/.xinitrc
 move the cursor to the line where is written : xset s noblank
Write a new line after this:
xset s 100 ( where 100 is the delay seconds)
or type
xset s off (where off will disable the screen saver)
 save file exit from xmeditor and make a reboot.

(Maybe you already have the line <<xset s off>>; so you have to check whether there is
another line where is written:
Prio -4 Xmiss -initial 100 -bt150 -module dim &
You can change the delay value 150 to 300 (that means a delay of 300 seconds=5minutes)
1
unix commands 0

Changing the time on XNC

type ---> su
type ---> date[spazio]9702201151.00

Entering X-terminal

If you cannot enter X-terminal through the usual procedure, you can enter as follows:

ctrl alt backspace


when user name: is asked, type root
If you in any case cannot work with the X-terminal try pressing
ALT-F2.

If the NC locks at the start up giving the message File or directory


doesn’t exist

If the NC says that the file or directory /etc/utmp doesn’t exist, the client may have ruined
the file Xconfig entering from X-terminal with the command configX. When the machine
starts up, after the checksum the message FILE OR DIRECTORY DOESN’T EXIST is displayed.
To solve the problem, enter with Ctrl C and root (alt F2)
enter the dir typing cd /usr/lib/X11/Metro
in this dir there should be the files Xconfig.compatto e Xconfig; the latter ir damaged.
Then, you must copy the file Xconfig.compatto to Xconfig typing cp Xconfig.compatto
Xconfig
then, make a reboot -ah

Length of the XNC program names

The names of the XNC programs must be of 8 characters max. so as to prevent any
problems while transferring with the diskmanager and uploading by Optix.
The information to be set to restrict the (new) names to 8 characters is currently located in
the FLAG table of user tables, visible at password level No.16. The name of this information
is DOS FILE: if =1 the restriction is enabled.
With the version 1200 this information is available at a password level No.15 (OEMPWD), so
as to give the possibility of agreeing with the client the name restriction to all external
users. Usually it is set to 1.

With the next version 1202 this information will be available at a password level No.10
(SERBS).

Display card status

cat /dev/klog

At the execution of the command, the cards recognised by the control and those not
recognised are displayed.
1
unix commands 1

Checking if the Compiled PLC exists (previous version 1.2.0.0)

once compiled, it is in the directory:

c:/home/xnc/bin/plc-objs/

the file name is:

prog.oo (two letters o)

The other part of the PLC is named isaker and is located in the directory /home/xnc/bin/

Disk copy and check commands <cpdisk - verarc>

Together with the update disks, there is another disk containing files CPDISK and VERARC.
these files are for

copying disks
checking disks

You must first install the files to the hard disk as follows:
enter X-TERMINAL
type SU (superuser) and press Enter
insert disk CPDISK - VERARC
type INS and press Enter and follow the instructions of the NC.

Once the installation is finished, you can use these files any time you must do a copy of a
disk (also non UNIX):
you just have to type SU Enter, CPDISK Enter and follow the instructions of the NC.
with the file VERARC (archive check) you can check the disk integrity. You must make sure
that there are no strange errors or messages, but only the names of the files copied.

You might also like