Linux commands for SAP Basis administration:
Below are few useful UNIX commands which can be used in your daily task. Unix commands are case sensitive and be careful while running any of these commands.
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
3. Displaying the message which we had given?
Echo
4. what is the command for the calculator?
Bc
5. To record the session?
Script
6. To change the password?
Passwd
7. To get the users?
Who
8. To get the terminal characteristics?
Tty
9. displaying and setting the terminal characteristics?
Sty
File oriented commands:
1. What is the command to list out the contents?
Ls –l
2. what is the command to get the hidden files(.,..)?
Ls –a
3. what is the command to get the files in category wise(flagged)?
Ls –f
4. what is the command to get the directory attributes?
Ls –ld <directory name>
Eg: $ ls
–ld rajesh
5. in ls l 1 : what is the first character indicates?
drwxrxrx 2 mgurumur staff 1024 May
10 15:07 temp
Type of the file
file
d-directory
c-char file
6. what is the command to create a file?
Cat > file name
7. How to append the content to an existing file?
Cat >> file name
8. what is the end of file indicator?
Ctrl d
9. How to concatenate two files
Cat file1,file2>file 3.
10. How to remove a file?
Rm <file name>
11. While removing how to get the prompt for the removal{interactive remove}
Rm –I <file1,file2,file3>
12. What is the command for recursive file delete?
Rm –r .
13. What is the difference between “ cat <filename>” and “cat >
file name”
First command displays the content of the file
Second command creates the file
14. What is the use of “more” command.
To get the contents page wise
15. 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 ·
16. 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, getsreflected in all the
linked files
copy – creates separate files , changes in one is
not reflected in others.
17. How to find the total number of characters in a file
wc c <file> ·
18. To get the type of the file?
File
Eg: file chap01
19. Comparing two files?
Cmp
Eg: $cmp file1 file2———–prints the first
mismatch(character and the line)
File1 file2 differ: char 9, line 1
20. To get the common content in two files
comm.
Eg: comm file1 file2 – prints the common content in
both the files
21. To get the difference in two files and converting one file to other
diff
eg: diff file1 file2
22. To compress and uncompress the files?
Gzip and gunzip
23. To make an archive?
Tar
24. Compressing and archiving together?
Zip and unzip
25. How to change the permissions of a file
chmod
26. How to give the executable permission to the group?
Chmod g+x <file name>
27. What is the meaning of the command chmod 777 {4read,2
–write, 1execute}
rwx for user
rwx for group
rwx for others
28. Commands to transfer the files remotely
ftp,rcp,scp
29. What is the difference between rcp and scp?
Rcpremote copyno profound authentication
Scpsecured copycopied in a encrypted format, rate
of transit is high
30. 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>
2. what is the command to change the directory?
Cd <dir name>
3. how to move to the parent directory?
cd..
4. how to get the current directory?
Pwd, echo $home
5. how to remove the directory?
Rmdir , rm –r
6. 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.
7. how to copy the entire directory structure?
Cp R <dir1><new dir>
Process-oriented and filters:
1. What are the basic filters available?
Grep, sed.
Grep “pattern” <file name>
2. How to count for pattern in a file
grep c “pattern” <file>
3. What is sed?
Sed is used as a multipurpose filter .
4. How to increment value of a variable
a=expr $a + 1
5. How to check for various processes that are running on a system
ps ef
6. How will you execute a program so that it runs in the background
Program name &
7. 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 onehalf screen
<Control>u scroll up onehalf 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
0 Comments