Архив рубрики: Linux


#! /bin/sh
echo ‘$#’ $#
echo ‘$@’ $@
echo ‘$?’ $?

*If you run the above script as*

> ./test.sh 1 2 3

You get output:
$# 3
$@ 1 2 3
$? 0

*You passed 3 parameters to your script.*

$# = number of arguments. Answer is 3
$@ = what parameters were passed. Answer is 1 2 3
$? = was last command successful. Answer is 0 which means ‘yes’

SFTP fail

I think it may have to do with a welcoming message popping up after the successful login.
sftp doesn’t like welcoming messages.

Try to ssh in that server and see if any welcoming message pops up. It should be started from within ~/.bashrc so you can then comment out the respective line from there.

If you find yourself not knowing what to do, please post here the welcoming screen from an ssh session as well as the contents of ~/.bashrc

Определение открытых портов

После настройки сетевых служб важно обратить внимание на порты, принимающие подключения на сетевых интерфейсах. Любые открытые порты могут быть доказательством вторжения.

Просмотреть открытые порты можно двумя способами. Менее надёжный способ — опросить сетевой стек с помощью команды netstat -an или lsof -i. Этот способ не очень надёжен, так как эти программы не подключаются к компьютеру по сети, а просто определяют, что происходит в системе. По этой причине, эти приложения часто подменяются нападающими. Таким способом взломщики пытаются скрыть свои следы, если они незаконно открыли порты.

Другим более надёжным способом проверки открытых портов является использование сканера портов, например nmap.

Следующая команда, запущенная с консоли, определяет, какие порты ждут TCP-соединений из сети:


How to untar a tar file or gzip-bz2 tar file

  1. Type at the command prompt
    tar xvzf file-1.0.tar.gz — to uncompress a gzip tar file (.tgz or .tar.gz)
    tar xvjf file-1.0.tar.bz2 — to uncompress a bzip2 tar file (.tbz or .tar.bz2) to extract the contents.
    tar xvf file-1.0.tar — to uncompressed tar file (.tar)
    tar xvC /var/tmp -f file-1.0.tar — to uncompress tar file (.tar) to another directory
    • x = eXtract, this indicated an extraction c = create to create )
    • v = verbose (optional) the files with relative locations will be displayed.
    • z = gzip-ped; j = bzip2-zipped
    • f = from/to file … (what is next after the f is the archive file)
    • C = directory. In c and r mode, this changes the directory before adding the following files. In x mode, changes directoriy after opening the archive but before extracting entries from the archive.
  2. The files will be extracted in the current folder (most of the times in a folder with the name ‘file-1.0’).

Log all input and output in a terminal session

When you are ready to start recording a log file, type:

Now, until you stop the script, all input and output in the Terminal will be stored in screen.log. When you are done, just type:

Your screen.log file will be in your Home folder (/home/user). This will do exactly what you are looking for.

ShrewSoft VPN as an alternative to CiscoVPN

Assume you have been given connection information for a Cisco VPN server:


Password: *318#($@

User ID: ian@superuser.com
Password: ianvendor1234

These are the steps to use ShrewSoft VPN to connect to the Cisco VPN server, rather than the Cisco client:

  1. Create a new connection, and under Host name or IP Address enter the Host address (
  2. On the Authentication tab, select Authentication Method of Mutual PSK + XAuth:
  3. On the Client set  force-rfc in NAT traversal
  4. On the Authentication -> Local Authentication tab select Identification Type of Key Identifier:
  5. Still on the Authentication -> Local Authentication tab, enter Key ID String of SUPERVENDOR:
  6. On the Authentication -> Credentials tab, enter your Pre Shared Key of *318#($@:
  7. Save the newly created connection, and click Connect
  8. When prompted for a username and password, enter your supplied User ID and Password, and click Connect:
  9. Run Shrew on LINUX:
    1. Start daemon sudo iked
    2. Run GUI qikea

Dictionary for Mozilla Firefox (Linux) ru_en

Installation instructions
1. Download Russian dict from ru_RU.
2. Find folder with hunspell dictionaries. It is probably

3. Merge Russian and English dict with hunspell-merge.
4. Go to the folder where you have saved the downloaded files and copy them to hunspell folder using command:

5. Find folder with myspell dictionaries. It is probably

6. Make in this folder symbolic links to files prg.dic, prg.aff with the same names using commands:

7. Start Firefox. In a field where it is possible to write press the right mouse key and select check spelling. Next again press the right mouse key. Now there should be visible Languages in the menu. Go there to the list of languages and select prg. From now the automatic spell-checking is activated.

How to copy files from a damaged hard disk with Linux

I just got a hard disk which had bad blocks to try to rescue files, but which was too big to use dd_rescue to copy the whole partition on any other hard disk I had, before extracting the files. But in this case the file system directory structure was still readable, so I was able to use following method, which maybe helps someone else.

1. Install dd_rescue:

2. Mount the file system read only with following

3. Create 2 shell scripts.

First File:

Second File:

I use 2 scripts as sometimes the hard disk runs into a problem and than stops working until it is powered down and up again. In this case I use CRTL-C to break the loop followed by commenting the first 3 commands in the first file out, and than start it again after the harddisk is mounted again. The “if”-query in the second file makes sure we won’t try files which we already have or the one which lead to the error in the first place.