PDA

View Full Version : Common used Unix/Linux telnet commands



Sicilian
16-04-10, 10:27
Thought it would be a great idea to have commonly used telnet commands in one place. Please post any that are missing.

Telnet Commands Basic Navigation

cd
When typed by itself, cd (”change directory”), will take you back to your $HOME directory
cd /path/to/directory
To change to a specific directory, type cd followed by the path to the directory. If it is a subdirectory of the current directory, you can just type the directory name.
cd ..
Typing cd .. moves you up one directory from your current location.
pwd
To see which directory you are in, type pwd (”print (display) working directory”).
exit
Just as it sounds, use exit to log out. Alternatively, you can type logout.
Creating and Deleting Directories

mkdir directoryname
To create a new directory, type mkdir (”make directory”) and specify the new directory’s name.
rmdir directoryname
To delete an empty directory, type rmdir (”remove directory”) and the directory’s name.
Listing Files

ls
To display a list of files and subdirectories in your current directory, type ls (”list”)
ls -a
To see a more complete list which includes hidden files or files that begin with a “.” (dot), type ls -a.
ls -la
To list all files and directories in long format which will provide details about each file and directory, type ls -la.
ls -lS
To list all directories and files, sorted by size, in long format, type ls -lS.
ls -lta
To list all files and directories in long format by time modified, type ls -lta.
Copying Files

cp oldfilename newfilename
Will copy the contents of one file to another file, resulting in two copies of the same file on your account.
cp directory/* destinationdirectory
Will copy the contents of one directory to another directory. Make sure you have created the destination directory before trying to copy files to it - see mkdir above. Results in two copies of the files on your account; one copy in the existing directory and another in the destination directory.
Searching FIles and Directories

find -name ‘n*’
The find command can be used to locate files or a group of files. It can also be used to display directories. The example given will find all file and directory names within the current directory and subdirectories of it that begin with the letter n. (You can also explore using the locate command - type info locate and/or man locate for usage information.)
grep -inw text filename
Can be used to locate text in a specific file or directory of files (use * in place of filename to search all of the files in the current directory). The -i argument indicates the search is to disregard cASe, the -n instructs to show the corresponding line number, and -w tells it to match only based on the whole word. (This doesn’t even begin to touch on the power of grep and its many uses. In addition to its searching capability, the grep command can be used in combination with other commands to act as a filter. It also allows the use of “wildcards”. Two other variations of grep are also available, egrep and fgrep. To begin your quest for more information, type man grep and/or info grep.)
Displaying / Comparing File Content

wc filename
Counts and displays the number of lines, number of words, and number of characters of the given file.
cat filename
Displays the entire contents of a file.
nl filename
Shows the content of the file, including line numbers (nl=number lines).
more filename
Displays the contents of a file one screen at a time. Press the SPACEBAR to display the next screen of text.
cmp filename1 filename2
Compares the contents of the two named files and reports the first different character found and the line number.
diff filename1 filename2
Compares the contents of the two named files and reports all of the differences found. (Can also be used for comparing the contents of two directories.)
Moving, Renaming, and Deleting Files

mv oldfilename newfilename
Can be used to rename a file (mv fileA fileB), move a file (mv fileA /dirA/), or both (mv fileA /dirB/fileB).
rm -i filename
Removes (deletes) the specified file. (The -i is not necessary, but is recommended as it will prompt you to confirm the action first. When prompted, type y to confirm or type n if you changed your mind.)
Changing Permissions

chmod permissions filename
Changes the permissions on a filename or directory as specified. For example, chmod 755 startup.sh.
Archives and Compression

tar -cfv filename.tar directoryname
To archive a directory and all of its contents including subdirectories, navigate to where the directory is located and type the above command, replacing filename.tar with the name you wish to give the archive file and directoryname with the name of the directory you wish to archive. Alternatively, you can archive a select group of individual files (or directories) by specifying each file name in place of directoryname separated by spaces, like tar -cvf filename.tar fileA fileB fileC. Note: When creating a tar file (aka “tarball”) be sure to specify the name you wish to give the tar file! (TAR indicates Tape ARchive, as it was originally a tape archiving program. The -c means “create”, v means “verbose” (which basically says tell me what you’re doing), and the f indicates that a filename will follow (filename.tar)).
tar -tvf filename.tar
Typing this command will result in a list of the contents of the tar file. This is generally a good thing to do before unpacking the tar file to be sure there are no matching filenames which will result in files being unintentionally overwritten.
tar -xvf filename.tar
You can see the similarities to the command used to tar the file. This time, though, you use -x to “extract” instead of the -c used to create. You can also extract only certain select files (or directories) by specifying the individual names, separated by spaces, after the tar filename, such as tar -xvf filename.tar fileA fileC
gzip filename.tar
This utility, gzip (gnu zip), is used for compression. Normally, when you wish to compress a set of files, you willtar them first then compress them using this command. In doing so, the filename will automatically change from filename.tar to filename.tar.gz (appending .gz to the file extension).
gunzip filename.tar.gz
This command (g”unzip”) is used to uncompress a .tar.gz file, which will also result in the filename being changed back to filename.tar. Once it has been uncompressed, you can then untar it using the tar command above. (Alternatively, you can use gzip -d (for “decompress”) in place of gunzip.)

tar -czvf filename.tgz directoryname
This command, which uses a z switch (”zip”), allows you to take a bit of a shortcut instead of using the tar and gzip commands separately. The example will result in a compressed archive named filename.tgz.
tar -xzvf filename.tgz
This command is used to uncompress and extract the files from a .tgz archive.
ipkg install /directory name/filename.ipk
This command is used to install a .ipk file.



Use fdisk to create partition
(WARNING: Ensure you have taken backups of any data you want to keep from all devices, I do not assume responsibility for any data lost!!!):

You will first need to unmount the device you want to re-partition. To do this, use the command umount device, for example umount /dev/sda

Then, you can start to partition the device:
fdisk device. For example, fdisk /dev/sda

To get help in fdisk, enter the letter m, followed by enter press. The most common commands used are:

p - print the partition table
n - create a new partition
d - delete a partition
q - quit without saving changes
w - write the new partition table and exit
t - change a partition's system id

Changes you make to the partition table do not take effect until you issue the write w command.

First off, list all the partitions on the disk by press the p. This should give you the partitions on your disk, an example would be:



Disk /dev/sda: 32.0 GB, 32006733824 bytes
17 heads, 17 sectors/track, 216308 cylinders
Units = cylinders of 289 * 512 = 147968 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 213474 30846984+ 83 Linux
/dev/sda2 213475 216308 409513 82 Linux swap


Delete all current partitions, by pressing d. This may ask you for the partition number (may not if you only have 1 partition. In the example above, I would choose 1 for sda1, and 2 for sda2. Delete all partitions.

Now, we can just press n to create the new partition(s). This will ask if you want an extended or primary. Choose primary by entering p. Now, enter 1 as the partition number. If you are just going to do the 1 partition, just press enter when it asks you for the first cylinder and last cylinder.

However, if you want a swap partition, or 2 partitions, then you will need to calculate the cylinder values you need for the sizes you want to set. In my example of the partitions above, I want a 400mb swap file. From the number of bytes, I can do 32006733824 (number of bytes) divided by 1024 which gives 31256576kb. I now need to divide it by 1024 again, to give me MB, which equals 30524MB. So, to have 1 partition as the main drive (of the majority of disk) and another as swap with 400MB, I will do 30524 minus 400, which gives me 30124. Now, to work out how many cylinders to use for the first partition (~30124MB), we need to work out the ratio. So, 30124/30524 gives us a ratio of 0.9869. So, for partition 1, we want 216308 * 0.9869 cylinders (which is 213474 (rounded). So, when I am asked for the first cylinder, I would enter 1 (as we want it to start at the beginning), and then when I'm asked for the last cylinder, I would enter 213474. Then, I would follow through, and choose the process again (n to create a new partition), choose primary (p), then enter 2 as your partition number. Now, when it asks the first cylinder, you can just press enter for the default value given (first free cylinder, which is 213475). You can also just press enter to accept the default value for the last cylinder. If you now choose p, this should give you the table, as shown above, except the sytem is Linux on both, instead of Linux Swap for the swap partition...

So now, we need to press t to change the system ID so the system recognizes it as a swap partition. You will be asked which partition to change the system id. In this case, it would be 2. You should now enter 82, as this is the code for a linux swap. You will now receive a message to say you've changed the partition type. Now, pressing p to print the partition table, will give you the same as the code above... Now, we just need to write it by press w.

You can now proceed to format the partitions for use in linux :)

Format a partition
(WARNING: Ensure you have taken backups of any data you want to keep from all devices, I do not assume responsibility for any data lost!!!):

Again, to format a partition, you must ensure your partition is not mounted. Issue the command umount device, for example umount /dev/sda1

Now, you can format the partition using the command:


mkfs.ext3 device (e.g. mkfs.ext3 /dev/sda1)

By default, five percent of the partition is reserved for use by the root user. This allows root to conduct administrative activities on the partition and perhaps move some data off. However, this is most critical when the partition contains / or home directories. For pure data partitions, this is just lost space. So, if you have a 1tb hdd, then 5% of this is ~50gb. A lot of wasted space. So, we can get the system to only use 1%, which is more negligable. To do this, we issue the command:


mkfs.ext3 -m 1 device (e.g. mkfs.ext3 -m 1 /dev/sda1

bobonthejob
16-04-10, 10:30
nice one...this will help out...

Mart
16-04-10, 12:27
Sweet m8 it will help me out also

Monty
16-04-10, 12:28
Nice info, I hope it dosen't cause Peter any stress :)

micscave
17-04-10, 00:10
Shit, now I'm scared !

oneforall
17-04-10, 00:13
Maybe a change of title to 'Commonly used Unix/Linux commands' is in order? ;)

Peter
25-04-10, 20:22
Sweet m8 it will help me out also

New knickers just from thinking about it. Haven't got the box yet. All I ask is that its all in English

Monty
25-04-10, 20:24
Peter.
My I ask what your principal requirements for the box are?
Is it just a means to view TV channels, or is there a need to play and understand?

Ojustaboo
12-06-10, 00:56
Another handy unix command is using the pipe to string things together.

The pipe is the | key to the left of the Z key on a standard UK keyboard (shift + \).

For example, if your in a directory with pages of files, to get them listed one page at a time you can do

ls | more

or

ls -a | more

If you wanted to list all files containing the word tux, you could do

ls -a | grep tux

if there was pages of them, you could do

ls -a | grep tux | more

pooface
25-06-10, 14:05
Managed to get mine from a telnet session (windows mobile phones are great :p), by typing the command:


hdparm -I /dev/sdb1 | more

Need the more since the telnet client on phone won't let me scroll back to previous pages, but on a computer you should be ok without the more... The /dev/sdb1 needs to be changed to whatever your mount point for the hdd is derived from (type mount in a telnet session to find out).

Gives output along the lines of:



ATA device, with non-removable media
Model Number: eSATA-2 Freecom
Serial Number: XXXXXXXXXXXX
Firmware Revision: 0


hth :)

Ojustaboo
21-07-10, 10:50
Just discovered a couple more :)



grab /tmp/whatever.bmp
will create a screen shot of what's currently displaying on your tv (tv program, menu etc)



This next one is interesting (possibly). It reboots your box while staying connected to your telnet session (which must mean it doesn't fully reboot else you'd loose the connection) and puts every detail of what it does on your screen. Once your box is up and running, everything you do on your box is reported in detail (what the systems doing) on your telnet screen.



init 4
enigma2when you've had enough,



<CTRL C> (to exit out of the log)
init 3 (to reboot back into normal mode)

yngvekl
07-09-10, 00:33
If using vi to edit some file, and by accident pressing ctrl+zz instead of shift+ZZ, the job is getting reported as stopped [+1] or something. How to pick up the job again and continue?

/Yngve

Ojustaboo
07-09-10, 10:35
If using vi to edit some file, and by accident pressing ctrl+zz instead of shift+ZZ, the job is getting reported as stopped [+1] or something. How to pick up the job again and continue?

/Yngve

CTRL+z pauses the current task and throws you to the command prompt

simply typing
fg brings the current task back into the foreground


bg will make a task run in the background, although completely useless (wont do anything) for an editing task.


jobs will tell you which jobs you have stopped or running in the background.


jobs -l will also give you the process id so you could for example easily terminate it.

eg


vi pppp

CTRL+z

vi qqqq

CTRL+z

vi rrrr

CTRL+z


jobs
gives me



[3] + Stopped vi rrrr
[2] - Stopped vi qqqq
[1] Stopped vi pppp


jobs -l
gives me



[3] + 600 Stopped vi rrrr
[2] - 599 Stopped vi qqqq
[1] 598 Stopped vi pppp
typing the following will kill job no 2



kill -9 599
if I type the following immediately after using the kill command


jobs
I get



[3] + Stopped vi rrrr
[2] - Killed vi qqqq
[1] Stopped vi pppp
if I type jobs a few secs later, the job has disappeared and I get


[3] + Stopped vi rrrr
[1] - Stopped vi pppp
Using fg brings the last job that was stopped back into the foreground. If you want to specify which job you wanted to bring into the foreground, you can use

% in my above example, if I wanted to bring job no [1] (vi pppp) back into the foreground, I would simply type

fg %1

yngvekl
07-09-10, 11:13
Nice, thanks!! Now, since you obviously know your Linux, howto get the disk UUID in VIX? Tried some different commands (blkid, vol-something..) but no luck. Want to mount using uuid instead of normal procedure...

/Yngve

pooface
07-09-10, 11:21
Nice, thanks!! Now, since you obviously know your Linux, howto get the disk UUID in VIX? Tried some different commands (blkid, vol-something..) but no luck. Want to mount using uuid instead of normal procedure...

/Yngve

Dunno whether it works in the duo, but in linux, it should be:


vol_id --uuid /dev/sda1

And altering depending on the device you're wanting the uuid for...

yngvekl
07-09-10, 12:04
Don't think that command works in VIX..

Using DE BH i used uuid to mount. There was also this "by-uuid" directory somewhere (in /dev? can't remember exactly..)

/Yngve

levi45
07-09-10, 17:17
now i can play with my box bit more than just wach tv.....

pooface
10-12-10, 11:59
Just added the following to the sticky:


Use fdisk to create partition
(WARNING: Ensure you have taken backups of any data you want to keep from all devices, I do not assume responsibility for any data lost!!!):

You will first need to unmount the device you want to re-partition. To do this, use the command umount device, for example umount /dev/sda

Then, you can start to partition the device:
fdisk device. For example, fdisk /dev/sda

To get help in fdisk, enter the letter m, followed by enter press. The most common commands used are:

p - print the partition table
n - create a new partition
d - delete a partition
q - quit without saving changes
w - write the new partition table and exit
t - change a partition's system id

Changes you make to the partition table do not take effect until you issue the write w command.

First off, list all the partitions on the disk by press the p. This should give you the partitions on your disk, an example would be:



Disk /dev/sda: 32.0 GB, 32006733824 bytes
17 heads, 17 sectors/track, 216308 cylinders
Units = cylinders of 289 * 512 = 147968 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 213474 30846984+ 83 Linux
/dev/sda2 213475 216308 409513 82 Linux swap


Delete all current partitions, by pressing d. This may ask you for the partition number (may not if you only have 1 partition. In the example above, I would choose 1 for sda1, and 2 for sda2. Delete all partitions.

Now, we can just press n to create the new partition(s). This will ask if you want an extended or primary. Choose primary by entering p. Now, enter 1 as the partition number. If you are just going to do the 1 partition, just press enter when it asks you for the first cylinder and last cylinder.

However, if you want a swap partition, or 2 partitions, then you will need to calculate the cylinder values you need for the sizes you want to set. In my example of the partitions above, I want a 400mb swap file. From the number of bytes, I can do 32006733824 (number of bytes) divided by 1024 which gives 31256576kb. I now need to divide it by 1024 again, to give me MB, which equals 30524MB. So, to have 1 partition as the main drive (of the majority of disk) and another as swap with 400MB, I will do 30524 minus 400, which gives me 30124. Now, to work out how many cylinders to use for the first partition (~30124MB), we need to work out the ratio. So, 30124/30524 gives us a ratio of 0.9869. So, for partition 1, we want 216308 * 0.9869 cylinders (which is 213474 (rounded). So, when I am asked for the first cylinder, I would enter 1 (as we want it to start at the beginning), and then when I'm asked for the last cylinder, I would enter 213474. Then, I would follow through, and choose the process again (n to create a new partition), choose primary (p), then enter 2 as your partition number. Now, when it asks the first cylinder, you can just press enter for the default value given (first free cylinder, which is 213475). You can also just press enter to accept the default value for the last cylinder. If you now choose p, this should give you the table, as shown above, except the sytem is Linux on both, instead of Linux Swap for the swap partition...

So now, we need to press t to change the system ID so the system recognizes it as a swap partition. You will be asked which partition to change the system id. In this case, it would be 2. You should now enter 82, as this is the code for a linux swap. You will now receive a message to say you've changed the partition type. Now, pressing p to print the partition table, will give you the same as the code above... Now, we just need to write it by press w.

You can now proceed to format the partitions for use in linux :)

Format a partition
(WARNING: Ensure you have taken backups of any data you want to keep from all devices, I do not assume responsibility for any data lost!!!):

Again, to format a partition, you must ensure your partition is not mounted. Issue the command umount device, for example umount /dev/sda1

Now, you can format the partition using the command:


mkfs.ext3 device (e.g. mkfs.ext3 /dev/sda1)

By default, five percent of the partition is reserved for use by the root user. This allows root to conduct administrative activities on the partition and perhaps move some data off. However, this is most critical when the partition contains / or home directories. For pure data partitions, this is just lost space. So, if you have a 1tb hdd, then 5% of this is ~50gb. A lot of wasted space. So, we can get the system to only use 1%, which is more negligable. To do this, we issue the command:


mkfs.ext3 -m 1 device (e.g. mkfs.ext3 -m 1 /dev/sda1

canthackit
17-08-11, 06:43
Errrrrr
what's the telnet commands for starting and stopping CCcam please.

regards: canthackit

norhap
31-01-12, 20:00
I have the image mounted from hdd ViX 2.3 build 204.

but if I try to list the disk I get this error:


vuuno root @: ~ # fdisk -l
-sh: fdisk: not found
vuuno root @: ~ #

anyone know which command I have to use?

norhap
01-02-12, 00:07
good looking I found this,


blkid

but not if there will be any more complete command now it throws me the box.


vuuno root @: ~ # blkid
/ dev/sdb1: UUID = "A0AF-F47C"
/ dev/sda1: UUID = "-281b-41de 4e8a4edf-9821-b34c392160fa"

sunlight786
09-08-12, 20:35
can some one please write me a command how to restart enigima 2 from putty?which command?

Larry-G
09-08-12, 20:42
to re-start enigma 2 from a telnet session use

init 6

or

shutdown -r now

Trial
09-08-12, 21:51
hi,
restarting only enigma is done with
init 4
init 3

ciao

gesendet von meiner Tablette

CRMS
15-11-22, 16:51
I've got Telnet Client window on my laptop and connected to gigablue box via WLAN, so I have an ip address that works with OpenWebIf.

How do I actually connect the telnet to the box??

abu baniaz
16-11-22, 08:28
Type following in command prompt:
telnet "ip address of box"

eg.
telnet 192.168.1.25

CRMS
16-11-22, 11:14
Thanks. It worked.