Showing posts with label UNIX. Show all posts
Showing posts with label UNIX. Show all posts

Solution for UNIX Error: Terminal too wide


When you are working in an UNIX shell using Putty tool, you may get this error.

Problem: 

When you are trying to open vi editor, you may get error message "Terminal too wide"

How to Fix this??

Enter the below command in the shell and try to open vi editor again. It will work.


stty columns 120

Hope this will help on someone.

Different types of shell in UNIX and Linux


Unix Shell
A shell is  command interpreter between user and Unix kernel as well as provides a strong scripting language in UNIX
Following are the different types of Unix shells:
B shell - /bin/sh – This is the default Unix shell for many Unix operating systems .
Bourne shell was written by S. R. Bourne and its more emphasis is to use it as a scripting language rather than an interactive shell .
Some of the features are :
Provided support for environment variables using parameters and exportable variables.
Redirection of program output and error .
Command substitution using back quotes: `command`.
embed a file/commands using input redirector <<
“for ~ do ~ done” loops
“case ~ in ~ esac” for selecting and responding to a data value.
C-shell /bin/csh was designed to provide the interactive features lacking in b shell such as job control and aliasing .
K shell /bin/ksh – was created by David Korn and has features of both B shell and C shell along with some additional features .
Bash – the Bourne again shell was developed by GNU project .It is based on B shell language and has features of C and K shells.
tcsh is the default shell of FreeBSD and its descendants. Essentially it is C shell with programmable command line completion, command-line editing, and a few other features.
Zsh is a shell designed for interactive use and it has many of the useful features of bash, ksh, and tcsh along with many new features.
Unix Shell configuration files :

b shell
—————————————————–
shell prompt : $
executable file : /bin/sh
Read on interactive/non interactive login to bash
/etc/profile
~/.profile

bash shell
—————————————————–
shell prompt : $
executable file : /bin/bash
Read on interactive/non interactive login to bash
/etc/profile
~/.profile
~/.bash_profile
~/.bash_login
Always read on invoking bash
~/.bashrc
/etc/profile login login login
~/.profile login login

csh shell
——————————————————
shell prompt : %
executable file : /bin/csh
Read on csh shell invocation .
/etc/csh.cshrc
~/.cshrc
Read on interactive/non interactive login to tcsh shell
/etc/.login
~/.login
~/.logout
/etc/csh.login

ksh
—————————————————–
shell prompt : $
executable file : /bin/ksh
Read on interactive/non interactive login to bash
/etc/profile
~/.profile

tcsh shell
——————————————————
shell prompt : &
executable file : /bin/tcsh
Read on tcsh shell invocation .
~/.tcshrc
/etc/csh.cshrc
~/.cshrc
Read on interactive/non interactive login to tcsh shell
/etc/.login
~/.login
~/.logout
/etc/csh.login

zsh
—————————————————–
shell prompt : $
executable file : zsh
Configuration files :
Always read on invoking zsh
~/.zshenv always
/etc/zshenv always
only read on interactive login to zsh.
~/.zshrc
/etc/zshrc
Read on interactive/non interactive login to zsh
/etc/zprofile login
/etc/zlogin login
/etc/zlogout login
/.zprofile login
~/.zlogin login
~/.zlogout login


Tech Tip: Move your scripting/coding environment to the cloud by accessing your virtual workstations or virtual servers with 24x7 live support from CloudDesktopOnline.com. For other advanced cloud solutions and products visit www.Apps4Rent.com.

Script to find out particular file type in UNIX

In day to day system administration tasks, In some situations, you may need to find out a particular file type (ex: script files, regular files, etc..)  in large file systems. I had a situation to find out only script files (Shell and Perl Scripts) which are using "rsh" in the script code in a very large file system which contains more than 1,00,000 files.


I wrote a simple script to achieve this task. I am sharing this here, because this may be helpful to others as well.This script can be altered little to find out other file types as well.



#!/bin/ksh
find /GIS -type f | while read filename
 do
 filetype=$(file $filename | awk -F: '{print $2}'| awk '{print $2}')
 if [ "$filetype" == "script" ];then
    grep -i rsh $filename > /dev/null
    if [ $? -eq 0 ];then
       echo "$filename" >> /tmp/rsh_scripts_report
    fi
 fi
done

Finding disk space used by specific user in Linux and UNIX server

To find the disk space being used by a specific user:


# find . -user user1 -type f -exec du -k {} \;


Explanation of this command:


The -user option allows you to specify that find will only report files that are owned by the specified user. 


The -type option forces find to only return the path of items of a specific type (in this case, files). this prevents du from including directories, which might be owned by one user, but contain files for many users.


Then, for each found path, the du command is executed to report the disk usage.


To get summary information, i.e the total space used by a specific user: