sap errors and solutions

Just another SAP blog

UNIX commands for SAP BASIS Consultants

Below are few useful UNIX command which can be used in your daily task. Unix commands are case sensitive and be careful while running any of these command.

Listing of files:

  • ls -lt | more  : list of files, sort by date
  • ls -lR | more : list of files including sub directories (recursive mode).
  • ls -l | sort +4nr | more : List of files sort by size.

 

Space administration:

  • bdf . : Current file system usage.
  • bdf : List of the moutpoint with utilization and free space.
  • df -k : same as above but with more details.
  • df -k . : Current filesystem usage.
  • du -k : List of file with current utilization including sub directories.
  • du -k . : List of files with size in the current directory.

 

Create / Copy /  Move / ftp files:

  • vi <file_name> : Edit / change the file content. And also the same command is used for creating the new file.
  • mv <source_file> <target_path and target_file> : move a file from one location to other or same location. Ex. (mv abc.txt pqr.txt) (mv /home/abc.txt /home/Q47/abc.txt. Be careful while running this command.
  • cp <source_file> <target_path and target_file> : Make a copy of a file from one location to other or same location. Ex. (cp abc.txt pqr.txt) (cp /home/abc.txt /home/Q47/abc.txt. Be careful while running this command.
  • ftp <host_name> : Copy local files from windows machine to Unix server. Ex. below:
    • ftp sapux003
    • Will prompted user name and password and then it will connect to the UNIX server.
    • bin : Enable the binary mode.
    • hash : Enable the (#) mode.
    • put <file_name>

 

General Commands:

  • last : List of the users who logged into the system, ordered by current date.
  • top : List of process which are using high CPU, memory etc..
  • date : today’s date.
  • tail -f <file_name> : Will show the last few lines of the file, and also will update if the file is being modified.
  • tail -<last_line_numbers> <file_name> : same as above but will display the lines which you have mentioned in the option. Ex. tail -100 <file_name>.
  • pwd : show current directory.
  • uptime : System Uptime, from when the system is up.
  • ps -eaf | grep <process> : Process are running with the <text> Ex. ps -eaf | grep ora
  • w : currently logged on users.
  • whoami : Show which user you are logged in.
  • env : Show environment variables.
  • echo $<variable_name> : Show the variable output. Ex. echo $ORACLE_HOME.





Useful commands while working with SAP under UNIX:

  • dpmon : Work process list at OS level as SM50.
  • Jsmon : java process list at OS level
  • disp+work -V | more : Current version of the disp+work file.
  • R3trans -d <SID> : Check whether the R/3 is able to connect to the DB, the log will be generated at OS level in same directory as “trans.log”.
  • R3trans -x <SID> : Check whether the R/3 is able to connect to the DB, the detailed log will be generated at OS level in same directory as “trans.log”.
  • tp connect <SID> : Check whether the tp is able to connect to the DB or not.
  • SAPCAR -xvf <car/sar_file> : Uncar the SAR/CAR files.
  • Use the <SID>adm for SAP related activity.
  • Use the ora<SID> for oracle related activity.

 

General purpose utilities:

  1. what is the command to get the calendar?

Cal

2. what is the command to get the date?

Date

  1. Displaying the message which we had given?

Echo

  1. what is the command for the calculator?

Bc

  1. To record the session?

Script

  1. To change the password?

Passwd

  1. To get the users?

Who

  1. To get the terminal characteristics?

Tty

  1. displaying and setting the terminal characteristics?

Sty

 

 

File oriented commands:

  • What is the command to list out the contents?

Ls –l

  • what is the command to get the hidden files(.,..)?

Ls –a

  • what is the command to get the files in category wise(flagged)?

Ls –f

  • what is the command to get the directory attributes?

Ls –ld <directory name>                              Eg: $ ls –ld rajesh

  • in  ls -l  what is the first character indicates?

drwxr-xr-x   2 mgurumur staff       1024 May 10 15:07 temp

Type of the file

  • file

d-directory

c-char file

  • what is the command to create a file?

Cat > file name

  • How to append the content to an existing file?

Cat >> file name

  • what is the end of file indicator?

Ctrl d

  • How to concatenate two files

Cat file1,file2>file 3.

  • How to remove a file?

Rm  <file name>

  • While removing how to get the prompt for the removal{interactive remove}

Rm –I <file1,file2,file3>

  • What is the command for recursive file delete?

Rm –r.

  • What is the difference between “ cat <filename>” and  “cat > file name”

First command displays the content of the file

Second command creates the file

 

  • What is the use of “more” command.

To get the contents page wise

  • What is that command to copy a file and link a file.

cp sample1 sample2  – for copying sample1 to sample2

ln sample1 sample2   – for linking sample1 and sample2 ·

  • What is the difference between linking and copying files.

linking – links two or more files. Does not create another copy of the file.  Changes in one file, gets reflected in all the linked files

copy – creates separate files , changes in one is not reflected in others.

  • How to find the total number of characters in a file

wc -c <file> ·

  • To get the type of the file?

File

Eg: file chap01

  • Comparing two files?

Cmp

Eg: $cmp file1 file2———–prints the first mismatch(character and the line)

                      File1 file2 differ: char 9, line 1

  • To get the common content in two files

comm.

Eg: comm file1 file2 – prints the common content in both the files

  • To get the difference in two files and converting one file to other

diff

eg: diff file1 file2

  • To compress and uncompress the files?

Gzip and gunzip

  • To make an archive?

Tar

  • Compressing and archiving together?

Zip and unzip

  • How to change the permissions of a file

chmod

  • How to give the executable permission to the group?

Chmod g+x <file name>

  • What is the meaning of the command  chmod  777   {4-read,2 –write, 1-execute}

            rwx for user

            rwx for group

            rwx for  others

  • Commands to transfer the files remotely

ftp,rcp,scp

  • What is the difference between  rcp and scp?

Rcp-remote copy-no profound authentication

Scp-secured copy-copied in a encrypted format, rate of transit is high

  • What is the syntax for Scp?

scp [options] [[user@]host1:]filename1 …    [[user@]host2:]filename2

 

 

Directory oriented commands:

  1. what is the command to create a directory?

Mkdir <dir name>

  1. what is the command to change the directory?

Cd  <dir name>

  1. how to move to the parent directory?

cd..

  1. how to get the current directory?

Pwd, echo $home

  1. how to remove the directory?

Rmdir, rm –r

  1. what is the difference between rmdir and rm –r?

inorder to use the rmdir command the directory should be empty.

The rm –r itself deletes the sub directories.

  1. how to copy the entire directory structure?

Cp  -R <dir1><new dir>

 

Process oriented and filters:

  • What are the basic filters available?

Grep, sed.

Grep “pattern” <file name>

  • How to count for pattern in a file

grep -c “pattern” <file>

  • What is sed?

Sed is used as a multipurpose filter.

  • How to increment value of a variable 

a=expr $a + 1

  • How to check for various processes that are running on a system

ps -ef

  • How will you execute a program so that it runs in the background

Program name &

  • How to bring background process to foreground

fg




Vi editor commands:

  • STARTING vi

vi filename    edit a file named “filename”

vi newfile     create a new file named “newfile”

  • ENTERING TEXT

i          insert text left of cursor

a         append text right of cursor

  • MOVING THE CURSOR

h            left one space

j            down one line

k            up one line

l            right one space

  • BASIC EDITING

X             delete character

Nx            delete n characters

X             delete character before cursor

Dw           delete word

Ndw         delete n words

Dd           delete line

Ndd          delete n lines

D             delete characters from cursor to end of line

R             replace character under cursor

Cw           replace a word

ncw          replace n words

C             change text from cursor to end of line

o              insert blank line below cursor

                  (ready for insertion)

O             insert blank line above cursor

                  (ready for insertion)

J              join succeeding line to current cursor line

nJ            join n succeeding lines to current cursor line

u              undo last change

U             restore current line

  • MOVING AROUND IN A FILE

w             forward word by word

b              backward word by word

$              to end of line

0 (zero)    to beginning of line

H            to top line of screen

M            to middle line of screen

L              to last line of screen

G            to last line of file

1G           to first line of file

<Control>f   scroll forward one screen

<Control>b   scroll backward one screen

<Control>d   scroll down one-half screen

<Control>u   scroll up one-half screen

n              repeat last search in same direction

N            repeat last search in opposite direction

  • CLOSING AND SAVING A FILE

ZZ            save file and then quit

:w            save file

:q!            discard changes and quit file

Other Commands:

sapstart check – display status of all instances at serverver
iostat -xm – disk utilization
df -i – inods utilization

Updated: December 13, 2016 — 11:20 am

11 Comments

Add a Comment
  1. Excellent documentation… This is must needed info for all basis consultants

  2. You should know a damm site more than this if working at os level.

    School boy stuff

  3. Very Nice Document

  4. Yeah agreed its really good for Basis folks….

  5. nice, but your editor changed something. It must be cat instead oft Cat, mkdir instead oft Mkdir and so on.

  6. Nice document mostly these commands.used in daily life of BASIS guys..Appreciated for this consolidated file.

  7. The idea is good, but with several editing errors. You must discriminante by platform, so it is not confusing.

  8. Thank you for the list.
    I’w extend it with the following:
    sapstart check – display status of all instances at serverver
    iostat -xm – disk utilization
    df -i – inods utilization

  9. Excellent document and could u please provide me document of java stack with linux

  10. Really very useful commands list for SAP BASIS guys

Leave a Reply

Your email address will not be published. Required fields are marked *

sap errors and solutions © 2016 Frontier Theme
Copy Protected by Chetan's WP-Copyprotect.