Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
vyvarya0608
Discoverer

Part 1:- SAP Basis OS support on SUSE Linux for beginners

As a SAP Basis consultants you are advised to understand the most commonly used Linux commands that are necessary while supporting SAP customers for day to day work. It is very common that basic commands should be handy with SAP Basis consultants.

Basic commands

Linux administrator can login with tools like putty or kitty or other applications available in market or allowed by customer, with either root or sidadm. Whereas both the IDs have different rights W.R.T  OS and sap application. ​

  •   ls  (  it is used to list  the directory  and files in the particular mount point/directory/path)​

vyvarya0608_0-1711553086365.png

 

“ls” will only show the list of files and directories on that particular mount point /directory/path.

 

Ls  - al  ( it will list directory/files as well as the hidden files)​

vyvarya0608_1-1711553086367.png

 

 

Ls  -ltr  (List all the files in the currently directory in ascending order)​

Ls -altr (adding a with it will show hidden files also in ascending order)

vyvarya0608_2-1711553086368.png

 

 

Ls  -lt  (List all the files in the currently directory in descending order)​

Ls -alt (adding a with it will show hidden files also in descending order)

Ls –ltr | more

 

vyvarya0608_3-1711553086369.png

 

 

cd dirname ( to jump into other directory)

vyvarya0608_4-1711553086369.png

 

Cd.. ( One step back of directory )​

vyvarya0608_5-1711553086370.png

 

Cd /  ( to come back to root directory)​

vyvarya0608_6-1711553086370.png

 

If you want to move to a directory on same path then you don’t have to use “/”.

But if you want to move to a directory outside of current directory or path then you need to use”/”.(give some practical examples)

 

info (given you the list of all commands available on OS)

vyvarya0608_7-1711553086371.png

 

vyvarya0608_8-1711553086374.png

 

 

  • Info <command>   (given you descriptive details of individual command)

 

vyvarya0608_9-1711553086376.png

 

vyvarya0608_10-1711553086377.png

 

 

  • <command> --help

(it gives you details of what all

Options are available for

Particular command)

vyvarya0608_11-1711553086379.png

 

 

  • pwd  ( shows the present working directory) ​

 

vyvarya0608_12-1711553086379.png

 

  • cat > filename  ( Using cat command we can create a file )

 

vyvarya0608_13-1711553086380.png

 

Cat  /etc/hosts ( To display file content)​

 

vi <filename>  (this is file editor)

vyvarya0608_14-1711553086380.png

 

 

  • head –10 filename 

( It will display first 10 lines of the file )

 

vyvarya0608_15-1711553086381.png

 

 

  • tail –10 filename

( it will display last

10 lines of the file)​

 

vyvarya0608_16-1711553086382.png

 

 

Managing files and directories

In this section of the article we will look at moving files and directories around the file system, copying files and directories and finally creating and deleting files and directories. The first command that we will look at is mkdir which creates directories. The mkdir command takes one argument which is the directory name you would like to create

 

vyvarya0608_17-1711553086383.png

 

 

The mkdir also accepts brace expansion which allows you to create multiple directories with one command

 

vyvarya0608_18-1711553086385.png

 

As you can above four directories were created ‘tes1’, ‘tes2’, ‘tes3’ and ‘tes4’. The second command I executed contained an asterisk (*) this character is known as a wild card and means any character

 

  • RM and RMDIRcommand (used to remove files and directories)

rmdir command – Deletes the specified empty directories and folders in Linux.

rm command – Delete the file including sub-directories.​

If you use RMDIR to delete a non empty directory, you will get an error message:-

rmdir: <directory name> :Directory not empty.

 

 

The other command that we will look at is rmdir. This command removes directories from the file system. However, when using this command the directory has to be empty otherwise the directory will not be removed. The rmdir command takes one argument which is the name of the directory you would like to remove. The rmdir command also accepts brace expansion which is identical to mkdir.

 

vyvarya0608_19-1711553086385.png

 

Lets run some practical commands.

 

The another command that we will look at is cp. This command is used for copying files from one location to another. The cp command takes a wide variety of qualifiers, however, we will only be supplying two arguments with the cp command.

vyvarya0608_20-1711553086387.png

 

You will also notice that the original copy is still in its current location.

 

 

The another command that we will look at is mv. This command is used for renaming files and moving them from one location to another. The mv command takes a few qualifiers and requires at least to arguments, if you are moving a file from one location to another you have to specify the first argument as the filename and the second argument as the destination directory, if you are renaming a file your first argument should be the filename and the second argument should be its new name.

 

vyvarya0608_21-1711553086388.png

 

the file was successfully renamed and the ‘test.txt‘ filename no longer exists because it had been renamed.

 

 

As I mention previously the mv command can be used to move files and directories from one location to another.

 

vyvarya0608_22-1711553086389.png

 

 

In this section of the training we will look at finding files using two different methods. The first command that we will examine is find. This command has some very powerful features for finding files such as searching by: file access time, file size, filename, file contents, etc.

The first file that we will try and find is ‘passwd‘, the first command we will use is find.

 

vyvarya0608_23-1711553086390.png

 

 

Qualifier

Description

/

This argument is where you specify the path in which you would like to search.

-iname

This qualifier tells the find command that we are performing a case insensitive search.

public_html

This directory is used to store HTML content. When the Apache web server has been enabled and has the UserDir option enabled this directory is published on the Internet.

passwd

This argument is where you specify the file which you would like to search for.

 

The second example we will do with the find command is find a file which has the keyword ‘damian’.

 

vyvarya0608_24-1711553086391.png

 

 

Qualifier

Description

/etc

This argument is where you specify the path which you would like to search. In this example we search the /etc directory.

-type f

This qualifier specifies that we only want to check regular files.

| xargs grep -l -i “damian”

This section of the command retrieves the filename via a pipe (|) and passes the filename into the grep utility which search for the keyword ‘damian’ and prints out the filename which contains the keyword.

 

The another example that we will look at when using the find command is to find files that have a size greater than 500MB.

find /root -type f -size +500M -printf "The %p file is greater than 500MB\n“

 

vyvarya0608_25-1711553086392.png

 

Once you have got the hang of the find command you should have no problems finding your files.

 

Qualifier

Description

/root

This argument is where you specify the path which you would like to search. In this example we are searching root’s home directory.

-type f

This qualifier specifies that we only want to check regular files.

-size +500M

This section of the command specifies the file size we would like to search for.

-printf “The %p file is greater than 500MB\n”

This qualifier prints a custom message telling the user we found a file greater than 500MB.

 

In this section of the training we will look at how to create hard and soft symbolic links. A symbolic link is a reference to another file similar to Microsoft Windows shortcuts. However, Linux has two types of symbolic links. The first type of symbolic link is ‘soft’ which points to filenames instead of the file’s inodes and the second type of symbolic link is ‘hard’ which actually points to the inodes and not the filename.

You cannot create hard links across multiple devices e.g. If you have created separate partitions for /home and /usr you cannot hard link any files from /usr to /home. However, you can create soft links across multiple devices.

The command that you use to create symbolic links is ‘ln‘. This command with no qualifiers and two arguments will create a hard link. However, if you want to create soft links you need to provide the -s qualifier. 

 

vyvarya0608_26-1711553086392.png

 

the first argument is the actual filename you would like to point to and the second argument is where you want the symbolic link (shortcut) to be.

The below example creates a soft symbolic link for the ‘cal‘ utility which is stored within the /usr/bin directory.

vyvarya0608_27-1711553086394.png

 

the ‘cal‘ utility was successfully created and ‘ls -l’ shows that the /root/cal file points to the /usr/bin/cal file. 

Creating a hard symbolic link to the ‘cal‘ utility.

vyvarya0608_28-1711553086396.png

 

the hard link was successfully created and it does not show a pointing arrow when issuing the ‘ls -l‘ command. This is because hard links point directly to inodes and not the filename.

 

STAT command:

the ‘stat‘ command being executed which allows you to examine a file more thoroughly.

 

vyvarya0608_29-1711553086398.png

 

Compressing Files

In this section of the training we will look at how to compress files and directories. The utilities that we will be working with are ‘tar‘ (The GNU version of the tar archiving utility) and ‘gzip‘ (Compress or expand files).

gzip is a compression utility and requires the assistance of tar when compressing directories. The first utility that we will examine is tar. tar is used for archiving multiple files and directories which later can be compressed using gzip.

SYNTAX:-    

vyvarya0608_30-1711553086398.png

 

 

The first example will involve using ‘tar‘ to archive the user Damian’s home directory. Below shows the command used to archive Damian’s home directory and Table 1 explains what each qualifier supplied with the ‘tar‘ do.

vyvarya0608_31-1711553086399.png

 

you will notice that you have a newly created archive within your current working directory.

 

Qualifier

Description

-c

Creates a new archive.

-f damian.tar

Use archive file.

 

 

The archive can be viewed using the ‘tar‘ command as shown below.

vyvarya0608_32-1711553086400.png

 

 

Tar also allows you to exclude certain files and directories by using the ‘–exclude’ qualifier and you can also append files to a tar archive by using the ‘-A’ qualifier.

Once you know how to archive a directory and view the contents of a ‘tar‘ archive you will also want to know how to extract files from the archive. Below shows the command used to extract all the files and directories stored within a ‘tar’ archive.

vyvarya0608_33-1711553086401.png

 

Qualifier

Description

x

Extract files from an archive.

v

Verbosely list files processed.

f

Use archive file.

 

 

Now that you have an idea on how to use ‘tar‘ we will look at how to use gzip to compress files. The first file that we will compress is the ‘damian.tar’ which we created earlier. Below shows the command used to compress the ‘damian.tar’ archive.

 

vyvarya0608_34-1711553086402.png

 

Qualifier

Description

-9

Compress better.

-1

Compress faster.

-d

Decompress the compressed file.

-v

Verbose mode.

-r

Operate recursively on directories.

-l

List compressed file contents.

 

You will notice the file now has the extension .gz which is a sign that the compression was successful. The next step is to decompress the compressed file using ‘gzip‘. The process of decompressing the file is simple since you only need to supply the -d qualifier followed by the filename.

 

vyvarya0608_35-1711553086402.png

 

Once you have decompressed the ‘damian.tar.gz’ file you will notice that the prefix .gz disappears and you will notice the file has been decompressed.

 

In this section of the training we will look at how to determine a file type e.g. Binary files, text files, compressed archives and many others. In Linux it is not necessary to give extensions to files, however most people do give extensions just for readability. What would you do if you had a directory full of files and none of the files had extensions? Well it’s simple! There is a utility called ‘file’ which determines the file type for any file.

 

vyvarya0608_36-1711553086402.png

 

 

In this section of the training we will look at the ‘history‘ command. The ‘history‘ command is a very useful command as it allows you to track your previously typed commands. If you type ‘history‘ on its own you can view the majority of the commands you have typed as shown below.

 

vyvarya0608_37-1711553086404.png

 

The ‘history‘ command returned a list of commands along with a line number. This line number can be useful if you don’t want to type the command out again you can issue an explanation mark (!) followed by the line number and the command will be executed as shown below:-

 

vyvarya0608_38-1711553086404.png

 

The ‘history‘ command can also be a little bit of a pain as some users may accidentally type there root password when trying to use the ‘su‘ command to become the root user and the password gets stored within the history. The ‘history‘ command provides a qualifier (-c) which will clear the all the history thus allowing you to erase an previous commands you typed or any accidental passwords you may have typed. It only saves credentials if you are using “su” not if you are logging normally.

 

LETS CONNECT OVER PART 2 AND PART 3 OF THIS KNOWLEDGE SHARING TO EXPLORE MORE COMMANDS……

Any suggestions and corrections are most welcome.

Labels in this area