In shell we can almost everything. But let’s divide issue into 3 part: LINES, WORDS, CHARACTERS Part 1 – Lines Q. How to create histogram of lines? Test file [root@hostname]# cat test aaaa aaaa aaaa bb bb cccccc dddd dddd dddd dddd The answer is uniq – great unix command, below some examples, the last on is the best [root@hostname]# cat test | uniq -c 3 aaaa 2 Read More ...
Task: Create environment for downloading files. Limtations: - open port 22 - protocol scp - exchanged ssh keys Platform: - Linux, AIX, HPUX, SunOS, Windows 2000, Windows 2003, Windows 2008 Start Simple remedy is to create chrooted user which hosts some files. In Network we can easly find some ready-made solutions like: SCPONLY https://github.com/scponly RSSH http://www.pizzashack.org/rssh/ But since OpenSSH 4.8 (http://www.openssh.com/txt/release-4.8) Added chroot support for sshd, controlled by Read More ...
Today some useful aliases. First of all definition: In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is Read More ...
The question is very simple and the answer could be. Basic approach [Unix]: tree -d which “List the contents of directories in a tree-like format.” And output [root@hostname etc]# tree -d . |-- NetworkManager | |-- VPN | `-- dispatcher.d |-- X11 | |-- applnk | |-- fs | |-- mwm | |-- serverconfig | |-- sysconfig | |-- twm | `-- xinit | |-- Xclients.d | `-- xinitrc.d |-- Read More ...
It’s true, on windows exists for loop, so as it is in this sentence: In computer science a for loop is a programming language statement which allows code to be repeatedly executed. on windows we can. It’s rather complex, there are a lot of syntaxes but, easy let’s start explaining. Syntax 1 – List FOR %%PARAM IN ([set]) DO CMD and example1 FOR %%P IN (item1 item2 item3 item4 item5) Read More ...
On Windows there is several different methods to obtain this. First is echo quit | telnet <hosntame> <port> And little snippet, when we are assuming that list of servers are store in file list.txt and port is 222 (why not?) for /F "tokens=*" %A in (list.txt) do @echo quit | telnet %A 222
This is a common tasks, and common question: How to check open ports on remote servers. Let’s assume than we have a servers list /tmp/list We can use a command nc on unix servers #!/bin/sh listfile=/tmp/list timeout=5 port=80 for item in `cat $listfile` do nc -v -w $timeout $item $port done It’s better than telnet because of possibility of using timeout params, which doesn’t exists in case of telnet On Read More ...
