CyberTek - the future at the present!
Google

Archive for the 'shell' Category

Finding text with grep

Posted by: (Nov 2)

Here is a simple way to search for text in a series of files, valid for all linux distros:

grep "my search string" / home / MyHome / *. txt

the grep command can also add other options:

- Perform a recursive search in sub-directories:

grep-r "my text" / home / MyHome

- Print only the name of the file where we have Notre occurrence:

grep-H-R "My Test" / home / MyHome

Published in: linux , shell , tips

nano editor, keyboard shortcuts and alternatives

Posted by: (Tue 21)
The notation for the abbreviations is as follows. The sequences identified by the symbol (^) are introduced using the Control key (Ctrl), or by pressing the Esc key twice. The sequences identified by the symbol Meta (M) can be inserted using either the Esc, Alt or Meta, depending on the configuration of the keyboard. In addition, pressing Esc twice and typing the numbers from 000 to 255 characters can be entered with the corresponding ASCII code. The following abbreviations are available in the main editor window. The alternative sequences are shown in parentheses:

^ G (F1) Show this help message
^ X (F2) Close the current file / Exit nano
^ O (F3) Saves the current file on disk
^ J (F4) Justify the current paragraph

^ R (F5) Insert another file into the current
^ W (F6) Search for a string or regular expression
^ Y (F7) Go to the previous screen
^ V (F8) Go to the next screen

^ K (F9) Cut the current line and stores it in cutbuffer
^ U (F10) cutbuffer Paste from the current line
^ C (F11) Shows the location of the cursor
^ T (F12) Run the spell checker, if available

M-\ (M |) goes to the first line of the file
M / (M-?) Should be the last line of the file

^ _ (F13) (MG) goes to a line number and column-specific
^ \ (F14) (MR) Replaces a string or regular expression
^ ^ (F15) (MA) Make the text at the cursor position
MW (F16) Repeat the last search

M-^ (M-6) Copy the current line and stores it in cutbuffer
Apply M-indent to current line}
M-{Remove indentation from the current row
Advance one character ^ F
^ B Decreases the font
^ Space forward one word
M-Space Decreases the word
^ P Move to previous line
^ N Move to next line

^ Go to beginning of current line
^ E Move to end of line
M-((M-9) to the beginning of the paragraph, then the preceding paragraph
M-) (M-0) Go to the end of the paragraph, then the next paragraph
M-] Go to the corresponding parenthesis
M-(M-_) Scrolls up one line without moving the cursor
-M + (M-=) Scroll down one line without moving the cursor
M-<(M,) goes to the previous buffer
M-> (M-.) Go to next buffer

Inserts a character literally MV
^ I Insert a tab at the cursor position
^ M inserts a carriage return at the cursor position
^ D Delete the character under the cursor
^ H Delete the character to the left of the cursor
MT Cut from the cursor to the end of the file

MJ Justify the entire file
MD Count the number of words, lines and characters
^ L Refresh the current screen
^ Z suspends the editor (if hibernation is enabled)

(MX) Command bar enables / disables
(MC) Always show the position of the cursor enable / disable
(MO) Use one row for more changes enable / disable
(MS) Continuous Scrolling enables / disables
(MP) Show white space enables / disables
(MY) Syntax colored enables / disables
(MH) Smart Home key enables / disables
(MI) Auto Indentation enables / disables
(MK) Cut to end of line enables / disables
(ML) Wrap enables / disables
(MQ) Convert tabs to spaces enable / disable
(MB) File Backup enables / disables
(MF) Multiple files enable / disable
(MM) Mouse Support enable / disable
(MN) No format conversion from DOS / Mac enables / disables
(MZ) Suspension enable / disable
(M-$) Wrap soft enable / disable

Published in: linux , linux nano , shells , tips

Increase ssh session length

Posted by: (Oct 5)

To prevent premature disconnection from a ssh session to reach a time limit of inactivity you can take the following steps:

1) A customer level, by modifying the file / etc / ssh / ssh_config, adding or changing the voice ServerAliveInterval, for example:

ServerAliveInterval 15

Set the retention time of the session to 15 minutes due to inactivity.

2) At the server level, edit the / etc / ssh / sshd_config, adding or changing entries and ClientAliveInterval ClientAliveCountMax, for example:

ClientAliveInterval 15
ClientAliveCountMax 15

The positions of the configs files may vary from one linux distribution to another, but usually the ones listed are the main paths, such as Debian, Ubuntu, Fedora, RH.

Published in: linux , shell , tips

List the packages installed on Ubuntu / Debian

Posted by: (set 21)

For a list of software packages installed on your Linux machine (Ubuntu / Debian):

dpkg-l | awk '/ ^ ii / {print $ 2}' | grep-v-e ^-e-dev-lib and $ (uname-r)> list.txt

Published in: linux , shell , tips

Resume broken download with rsync

Posted by: (July 26)

Here is an example of how to resume downloading a partially downloaded file via scp or rsync. Since scp does not support the resume, if siè started to download the file with this command, we still have to replace it with an alternative based on rsync:

rsync-partial-progress-rsh = "ssh-p 1022" root @ remotehost: / ~ / filename filename

In the above example is also shown how to compose the command if you are using a port other than the traditional 22 for the SSH protocol.

Published in: linux , shell , tips

Download files from Megaupload, Rapidshare and other services from Linux, via prompt

Posted by: (July 22)

Try using the high quality Plowshare (a program command line) Enlarged to perform the upload and download some of the most popular file-sharing websites. It runs on Linux and Unix-like systems, supports: Megaupload, Rapidshare, 2Shared, 4Shared, zSHARE, Badongo, DepositFiles and Mediafire. In practice it is a replacement for wget for these sites.

Plowshare to install in Ubuntu Linux

1. If not satisfied, complied with the dependencies:

  sudo apt-get install curl imagemagick tesseract-ocr-recode eng SpiderMonkey-bin aview 


2. Plowshare Download , extract and install the content. There is also a version already packetized. Deb, if you use that version you just double-click the package and confirm the installation, vice versa:

  tar xvzf Plowshare-0.x 


3. Now let's set up Plowshare:

  Plowshare cd-0.x 
  sudo bash setup.sh install 

Commands Plowshare

Downloading a file from rapidshare:
plowdown http://www.rapidshare.com/files/86545320/Tux-Trainer_25-01-2008.rar

Na u download the list of files (one per line):
plowdown file_with_links.txt

Downloading a file from rapidshare with free membership ID:
plowdown-a myuser: mypassword http://www.megaupload.com/?d=132348234

Download a password-protected file from rapidshare:
p-plowdown somepassword http://www.megaupload.com/?d=ieo1g52v

Get only the URL file without downloading it Actually. Very handy if you want to use another downloader Web:
plowdown-link-only http://www.2shared.com/file/4446939/c9fd70d6/Test.html | xargs wget-rt

For advanced users: If you find a page with several links to files hosted on rapidshare you download it, to see the first 10 links, you must use the following command:
curl http://some-website.com/page.html | \
grep-o "http://www.megaupload.com/ [^ \" <] * "| uniq | head-n10 | plowdown -

To filter the links operating in a text file:
plowdown file_with_links.txt c-> file_with_active_links.txt

Upload a file on rapidshare with free membershipID:
plowup-a myuser: mypassword-d "My description" / path / myfile.txt megaupload

Upload a file on rapidshare with a premium multifetch ID and uploads:
plowup-a myuser: mypassword-d "My description"-multifetch http://www.somewherefarbeyond.com/somefile megaupload

Upload a file on rapidshare anonomamente, changing the file name after upload:
plowup / path / myfile.txt rapidshare: anothername.txt

Published in: linux , rapidshare , shell

Linux console with screen sharing

Posted by: (July 4)

With screen you can share among multiple users sonsole connected locally or via ssh. To do so, please follow these steps, the instructions are typical for a debian system, but applies similarly for other distributions.

1. Install Screen

sudo apt-get install screen
2. From the host computer is run by the parameter screen to start a session screen-S SessionName. -S allows you to specify a name for the session, this allows you to manage multiple user sessions simultaneously and in a lot easier.
screen-S screen-test

4. The remote user (guest) uses SSH to connect to the remote computer (remotehost)

guest @ ssh remotehost
  5. The host computer (remotehost) consents to the connection in multi-user screen session by typing Ctrl-A: multiuser on (all 'command screen' start with the escape sequence Ctrl-A). 
CTRL-A: multiuser on

6. Then, the host (remotehost) must grant permission for the remote user (guest) to allow it to access the screen session with CTRL-A commadn: acladd user_name where user_name is the user's remote login.

CTRL-A: acladd guest

7. The remote user can connect to the host session. The syntax to connect to the screen session of another user is host_username screen-x / sessionname.

screen-x username / screen-test
Published in: HowTo , Linux , Shell , tips

How to format dates to display on a Linux shell

Posted by: (Apr 19)

In the shell you can specify the date format as follows:
date + FORMAT

For example, typing:
$ Date + "% m-% d-% y"

You get:
04-17-10

If you want the 4-digit year:
$ Date + "% m-% d-% y"

You get:
04-17-2010

The current time to drop one by typing:
$ Date + "% T"

You get:
19:55:04

To drop one time based on 12 hours:
$ Date + "% r"

You get:
07:56:05 PM

To display the time in HH: MM:
$ Date + "% H-% M"

You get:
07:56

Full list of options to format the dates wonder:

%%
a literal%
% To
Local's abbreviated weekday name (eg, Sun)
% A

Local's full weekday name (eg, Sunday)

% B
Local's abbreviated month name (eg, Jan)
% B
Local's full month name (eg, January)
% C
Local's date and time (eg, Wed 3 March 2005 23:05:25)
% C
century, like% Y, except omit last two digits (eg, 21)
% D
day of month (eg, 01)
% D

dates; Same as% m /% d /% y

% And
day of month, space padded; Same as% _d
% F
Full dates, exact as% Y-% m-% d
% G
last two digits of year of ISO week number (see% G)
% G
year of ISO week number (see% V); Normally useful only with% V
% H
Same as% b
% I

hour (00 .. 23)

% I
hour (01 .. 12)
% J
Day of year (001 .. 366)
% K
Hour (0 .. 23)
% S
hour (1 .. 12)
% M
month (01 .. 12)
% M

minute (00 .. 59)

% N
to newline
% N
nanoseconds (000000000 .. 999999999)
% P
Either the local's equivalent of AM or PM; blank if not known
% P
like% p, but lower case
% R
the local's 12-hour clock time (eg, 11:11:04 PM)
% R

24-hour hour and minute; Same as% H:% M

% S
seconds since 1970-01-01 00:00:00 UTC
% S
second (00 .. 60)
% T
Tabbed
% T
Time, Same as% H:% M:% S
% U
Day of week (1 .. 7), 1 is Monday
% U

Week number of year, with Sunday as first day of week (00 .. 53)

% V
ISO week number, with Monday as first day of week (01 .. 53)
W%
Day of week (0 .. 6), 0 is Sunday
% W
Week number of year, with Monday as first day of week (00 .. 53)
% X
Local's date representation (eg, 31/12/99)
% X
Local's time representation (eg, 23:13:48)
% Y

last two digits of year (00 .. 99)

% Y
year
% Z
+ Hhmm numeric timezone (eg, -0400)
% Z
+ Hh: mm numeric timezone (eg, -04: 00)
%:: Z
+ Hh: mm: ss numeric time zone (eg, -04: 00:00)
%::: Z
numeric time zone with: Necessary to precision (eg, -04, +05:30)
% Z
alphabetic time zone abbreviation (eg, EDT)

Published in: linux , shell , tips

How to mount Windows share in Linux

Posted by: (Apr 19)

To view the active sharing of advice to do before this command:

smbclient-L-U <windows-box> <username>

Then we can proceed to map the condivisionewindows in our linux box in Segun way:

  1. Create the directory for the mountpoint: mkdir / mnt / <name-of-mount-point>
  2. Mount the Windows share share:
    mount-t cifs-o username = <username>, <password> password = / / <win-box> / <share> / mnt / <name-of-mountpoint>
    Note: The syntax-<username> username =, password = <password> saves the password.
  3. Finally, if you want the drive to create the symbolic link: ln-s / mnt / <name-of-mount-point> / <path-of-symlink>

Published in: Linux , Samba , Shell , tips

Nano editor, syntax highlight

Posted by: (Feb 22)

To add syntax-colored nano in the first instance you must create the configuration file. Nanorc on their home page, as a second finding from this address: http://code.google.com/p/nanosyntax/source/browse/ # svn / trunk / syntax-nanorc files. nanorc be included in the configuration to achieve the desired effect.

Example text to be added to. Nanorc:

include "/ usr / share / nano / php.nanorc"
include "/ usr / share / nano / sh.nanorc"
include "/ usr / share / nano / java.nanorc"
include "/ usr / share / nano / patch.nanorc"
include "/ usr / share / nano / python.nanorc"
include "/ usr / share / nano / html.nanorc"
include "/ usr / share / nano / perl.nanorc"
include "/ usr / share / nano / ruby.nanorc"
include "/ usr / share / nano / js.nanorc"

Published in: linux , shell , tips

Shorcuts from bash

Posted by: (Oct 19)

Ctrl + A to the beginning of the line you are typing.
Ctrl + E Go to the end of the line you are typing.
Ctrl + L Clear the screen.
Ctrl + U Clears the screen before the cursor. If you are at the end of the line, clears the entire line.
Ctrl + R allows you to search through previously used commands.
Ctrl + C Stop whatever you are doing.
Ctrl + D Exit the current shell.
Start Ctrl + Z to suspend whatever you are doing in the background.
Ctrl + W Delete the word before the cursor is.
Ctrl + K Clear the line after the cursor.
Ctrl + T Reverses the last two characters before the cursor.
Esc + T Reverses the last two words before the cursor.
Alt + F Moves the cursor forward one word in the current row.
Alt + B Move cursor back one word in the current row.
Tab Auto-Complete the names of files and folders.
Paste Ctrl + Y (as in copy and paste) all the text before the cursor.

Note: Some of these commands do not work if you shell access via telnet, SSH session, or if the keyboard is a particular way configuratain

Published in: linux , shell , tips

Automated update of SpamAssassin Rules

Posted by: (Apr 20)

When you install SpamAssassin on our mail server we have installed a script used to download the rules to improve the capture of spam emails arriving on our server.

The script is called sa-update . Below we report a simple crontab entry to be included in your linux box to call every day at 7:00 am and to keep the script up to the dates of your spamassassin rules.

spamassassin auto update rules

0 7 * * * / usr / bin / sa-update-D-updated / etc / mail / spamassassin /

Remember to also restart the service after upgrading spamassassin with the command:

/ Etc / init.d / spamassassin restart

or

/ Etc / init.d / spamd restart

NOTE: Commands and locations can vary from distro to distro, but for the sysadmin should not be difficult to find the correct position. In case of difficulty please contact us or leave a comment.

Published in: linux , shell , spam , tips
Powered by CyberTek - Remote Assistance