Saturday, 8 July 2023

Essential Linux commands for beginners

Hello Friends!! Good Morning 😊

If you are working in Linux environment or managing the Linux server, you can't live without theses commands. So, in today's blog, I will discuss about some essentials Linux commands which are frequently used in Linux arena.


Let's come with me 😉

1. Print Working Directory[pwd]

When you type pwd in your Linux terminal and as soon as press the enter button, it will display your current working directory location. So, anyone want to know in which directory currently he/she is working, please use this command.

Syntax: pwd [OPTION]

There are two options available to display the locations-
-L, --logical : To display your location with any symbolic.
-P, --physical: To display your location after resolving any symbolic.

Example:
[brajesh@linux log]# pwd -L
/home/brajesh/logs
[brajesh@linux logs]# pwd -P
/var/logs

2. ls -Listing command

Well! guys, if you want to see the whole content of any directory you can you simply ls command. The main aim of this command is to see all files available in the directory.

Syantx: ls [option]

ls Option Description
ls -a In Linux, hidden files start with . (dot) symbol and they are not visible in the
regular directory. The (ls -a) command will enlist the whole list of the current directory including the hidden files.
ls -l It will show the long list.
ls -lh This command will show you the file sizes in human readable format.
Size of the file is very difficult to read when displayed in terms of byte.
The (ls -lh)command will give you the data in terms of Mb, Gb, Tb, etc.
ls --version It will check the version of ls command.
ls -li Will print the index number, if file is present in the first column.
ls -p It is used to identify the directory easily by marking the directories with a slash (/) line sign.
ls -r It is used to print the list in reverse order.
ls -R It will display the content of the sub-directories also.
ls -lt It will sort the list by displaying recently modified filed at top.
ls ~ It gives the contents of home directory.
ls ../ It give the contents of parent directory.
ls -n It is used to print group ID and owner ID instead of their names.
ls -d */ It is used to display only subdirectories.
ls --color=[VALUE] This command is used to print list as colored or discolored.

3. cd -Change directory

This changes the current directory. Note that it uses a forward slash. The example used here changes the location to a Linux directory that is present in all versions of Linux.

When you use ls –I you will be able to see more details of the contents in the directory. It lists the following:
  • Permissions associated with the file
  • The owner of the file
  • The group associated with the file
  • The size of the file
  • The timestamp
  • The name of the file
Example:
$ cd /var/log

4. grep -For searching the text.

This finds text in a file. The grep command searches through many files at a time to find a piece of text you are looking for.

Syntax: grep pattern [FILE_NAME]

Suppose you want to search 'error' in tomcat.log file, which is available under var/log. Then your grep command will go like this-
$ grep 'error' /var/log/tomcat.log

5. passwd-Change the password.

Though it looks similar to the pwd command, this command is very different. This command is used to change the user account password.

You could change your password or the password of other users. Note that the normal system users may only change their own password, while root may modify the password for any account.

Syntax: passwd [username]- changes the password for the user.

$ passwd admin 

6.  mv- Rename or move the file.

The mv command moves a file or renames it. Here the file name gets changed from first.txt to second.txt.
$ mv first.txt second.txt 
If you want to verify your changes, please to ls to see.

7.  cp- Copy command

This command copies a file. The cp command issues a copy of the file second.txt in the same directory.
$ cp first.txt second.txt 
You can use ls – lto see the new file created.

8.  rm- Remove file or directory

This command is used to remove files in a directory or the directory itself. A directory cannot be removed if it is not empty.

Syntax:
rm [name of the file]
rm –r removes all the contents in a directory and the directory as well.

$ rm file1.txt
$ rm -r myDirectory

9.  mkdir- Make a directory

The mkdir command makes a directory. The command is written as follows:
 
Syntax: mkdir [directory name]
$ mkdir myDirectory

10.  chmod- Make a directory

This command changes the mode of a file system object. Files can have read, write, and execute permissions.

Example:
  • chmod mode FILE
  • chmod 744 script.sh
  • The first number stands for the user who is associated with the file
  • The second number is for the group associated with the file
  • The third number is associated with everyone else who is not a part of the user or group
$ chmod 744 myDirectory

11.  chown- Change the owner

This command is used to change the ownership of a file/folder or even multiple files/folders for a specified user/group.

Syntax: chown [owner_name] [file_name]
$ chown admin1 file.txt
Assume that if you are a user named user1and you want to change ownership to rootuse “sudo”.
$ sudo chown root file.txt

12.  cat- Concatenate files 

The cat command (short for “concatenate”) is one of the most frequently used commands in Linux. cat command allows you to create single or multiple files, view contents of files, concatenate files (combining files), and redirect output in terminal or files.
$ cat file.txt
$ cat file1.txt file2.txt
The output will be the entire contents of the file(s).

13.  wc- Word count

The wc(word count) command is used to find out the number of new lines, word count, byte, and characters count in a file specified by the file arguments.

Syntax: wc [options] filenames
$ wc -l readme.txt
Shows the output as - 150 readme.txt
  • wc -l : Prints the number of lines in a file.
  • wc -w: Prints the number of words in a file.
  • wc -c : Displays the count of bytes in a file.
  • wc -m: Prints the count of characters from a file.
  • wc -L: Prints only the length of the longest line in a file.

14.  history- To show history

This command is used to show previously used commands or obtain information about the commands executed by a user.
$ history

15.  clear- To clear terminal

This command clears the terminal screen.
$ clear

16.  reboot- To reboot your system

This command halts, powers off, or reboots a system.
$ reboot

17.  diff- To compare two files

The diff command compares two files line by line to find differences. The output will be the lines that are different.
$ diff file1.txt file2.txt

18.  exit- To exit

The exit command exits the current shell. When you hit enter, you’ll be taken out of the terminal.
$ exit

19.  kill- To kill process

The kill command is used to end a process, usually an unresponsive one. The kill command also includes the process ID or the program name, as shown here:
$ kill 566789

20.  useradd- To add a new user

The useradd command creates a new user. The username is added after the useradd command, as follows:
$ useradd brajesh

Conclusion

We hope this Linux commands list will help you get started. These are just a few commands — there are many more that you’ll find yourself using over time, but this is a good starting point. The best way to learn Linux is by trying these commands yourself and also by taking course. Below we list the best Linux courses you can take today! 

Thank you !!! 😊








Tuesday, 11 October 2022

IBM: Rational ClearCase all cleartool commands

IBM: Rational ClearCase all cleartool commands

Hi Friends 😊, In today's blog we will talk about some important Cleartool commands which are very useful when you are working with IBM rational ClearCase tool.

What is IBM Rational ClearCase?💁💁

IBM Rational ClearCase provides controlled access to software assets, including code, requirements, design documents, models, test plans and test results.

For more details, please visit at- more info about IBM Rational ClearCase tool.

Now Coming on the Cleartool(ct) commands. While dealing with dynamic view in ClearCase tool, you should must aware about some important commands. Here I am going to index out some important ClearCase commands 👇-

Important ClearCase commands
---------------------------------------------------------------------------------------
ct help <command>                       Usage statement for command
ct man <command>                        Manual page for command
---------------------------------------------------------------------------------------
ct lsvob                                List VOBs
ct mount <vob-tag>                      Mount VOB
ct umount <vob-tag>                     Unmount VOB
---------------------------------------------------------------------------------------
ct lsview                               List views
ct startview <view-tag>                 Start view
ct setview <view-tag>                   Set view (UNIX)
ct endview <view-tag>                   Stop view
ct endview -server <view-tag>           Stop view and kill view server process
net use <drive:> \\view\<view-tag>      Map drive to view
net use <drive:> /d                     Disconnect drive from view
---------------------------------------------------------------------------------------
ct lsvtree <pname>                      Version tree browser
ct lsvtree -gra <pname>                 Version tree browser (graphical)
---------------------------------------------------------------------------------------

ct pwd                                  Print working directory
ct pwv                                  Print working view
ct ls                                   List contents of directory with ClearCase info
ct ls -view                             List only private files in directory
ct ls -vob                              List only vob elements in directory
----------------------------------------------------------------------------------------
ct lsprivate                            List private files in the view
ct lsco [-all] [-cview] [-s]            Find checkouts
----------------------------------------------------------------------------------------
ct mkview -tag <view-tag> <stg-dir>                     Create view
ct mkview -tag <view-tag> -stream <stream> <stg-dir>    Create view (UCM)
ct rmview -tag <view-tag>                               Remove view
----------------------------------------------------------------------------------------
ct mkstream <stream>                    Create stream (UCM)
ct lsact                                List activities at current stream (UCM)
ct setact <act-id> | [-none]            Set activities (UCM)
ct mkact -headline <headline>           Create activity (UCM)
ct rmact <act-id>                       Remove activity (UCM)

ct co [-unres] <pname>                  Checkout
ct ci <pname>                           Checkin
ct unco <pname>                         Uncheckout
ct reserve <pname>                      Change unreserved to reserved checkout
ct unreserve <pname>                    Change reserved to unreserved checkout

ct mkelem <pname>                       Make new file element
ct mkdir <pname>                        Make new directory element

ct mv <src-pname> <dest-pname>          Move an element
ct rmname <pname>                       Logical delete of element
ct ln [-s]                              Create link
------------------------------------------------------------------------------------------
<cmd> <pname>                           Operate on version selected by view
<cmd> <pname@@\version-id>              Operate on version given the version-id

ct diff [-gra] [-pred] <pname>          Diff tool
ct merge [-gra]                         Merge
ct findmerge                            Batch merge

ct mklbtype <label-type-name>           Create label type
ct mklabel <label-type-name> <pname>    Attach label
ct lock lbtype:<label-type-name>        Lock label

ct mkbl [-incremental | -full] <baseline-root-name>                Make baseline (UCM)
ct chbl [-level <promotion-level>]                                 Promote baseline (UCM)
ct chstream [-recommended <baseline-selector>] <stream-selector>   Recommend baseline (UCM)

ct rebase -gmerge -recommended          Rebase stream (UCM)
ct rebase -complete                     Complete rebase (UCM)

ct deliver                              Deliver activities (UCM)
ct deliver -complete                    Complete deliver (UCM)
ct deliver -activites <act-selectors>   Deliver specific activities (UCM)

ct setcs -stream                        Synchronize view

ct catcs                                View config spec
ct edcs                                 Edit config spec
ct setcs                                Set config spec

ct find                                 Search/Reporting utility

------------------------------------------------------------------------------------------

ct lsstgloc                             List all storage locations
ct mkstgloc                             Create storage location
ct rmstgloc                             Remove a storage location

ct mkvob -tag <vob-tag> <stg-dir>       Create VOB
ct rmvob <stg-dir>                      Remove VOB
ct describe vob:<vob-tag>               Display owner and group of VOB
ct protectvob                           Change owner and group of VOB

clearfsimport <src-path> <target>       Import files and directory structures
clearexport_*                           Export versioned files from another tool
clearimport                             Import versioned files

ct rmver                                Physically remove a version from VOB
ct rmbranch                             Physically remove an entire branch from VOB
ct rmelem                               Physically remove an entire element from VOB

ct relocate                             Relocate elements from one VOB to another

ct protect [-chown] [-chgrp] [-chmod]   Change element permission, owner, group
ct describe <element-path@@>            Display element permission, owner, group

mvfsstorage                             Display location of data container
ct dump                                 Display location of source and cleartext container

ct getlog                               Display error logs

ct mktrtype                             Create trigger type
ct mktrigger                            Attach/apply trigger
ct rmtrigger                            Remove a single instance of trigger
ct rmtype [-rmall] trtype:<trig-type>   Remove trigger type

ct mkattype <type-name>                 Create attribute type
ct mkattr <attype> <value> <pname>      Attach/apply attribute
ct rmattr                               Remove a single instance of attribute
ct rmtype [-rmall] attype:<att-type>    Remove attribute type

------------------------------------------------------------------------------------------

site_prep                               Prepare the ClearCase release area
setup / install_release                 Install ClearCase on client or server
clearlicense [-hostid]                  Display license information
rgy_passwd                              Set the registry password
ct hostinfo -l                          Display host ClearCase information

net stop albd                           Stop ClearCase services (Windows)
net start albd                          Start ClearCase services (Windows)
/etc/init.d/clearcase stop              Stop ClearCase services (UNIX)
/etc/init.d/clearcase start             Start ClearCase services (UNIX)

ct lsregion                             Display ClearCase regions
ct mkregion -tag <name>                 Create ClearCase region
ct rmregion [-rmall] -tag <name>        Remove ClearCase region

ct register (-vob|-view) <stg-path>     Register a VOB or view
ct unregister (-vob|-view) <stg-path>   Unregister a VOB or view
ct mktag (-vob|-view) -tag <tag> <stg>  Create a VOB or view tag
ct rmtag (-vob|-view) <tag>             Remote a VOB or view tag

rgy_check [-vobs] [-views] [-storage]   Verify registry integrity

ct lock vob:<vob-tag>                   Lock VOB
ct unlock vob:<vob-tag>                 Unlock VOB

ct recoverview -syn -tag <view-tag>     Recover stranded view private files

fix_prot                                Fix protection problems
dbcheck -a -k <vob_db>                  Scan RAIMA db for corruption
ct checkvob [-fix] -pool <vob-stg-dir>  Scan db/storage pools for consistency
..that's all. I tried to cover almost all commands..but still I missed any, please let me know in comment section. 
Thank You !!!!!!! 😉

Monday, 6 June 2022

How to Search a Text in VIM

 

How to Search a Text in VIM

Hello ! friends, So in today's notes we will talk about how we can search a string in VIM or Vi editor. Well! so lets start without wasting the time -
Vim/Vi is a powerful open -source command-line text editor. It is highly configurable with an extensive manual and ships with a wealth of features, including syntax highlighting and color codes, comprehensive plugin support, and search and replace, to mention a few.
Searching text or a string by manually scrolling up and down can be a very tedious task. Fortunately, the vim editor has a faster and convenient way of doing this.

Mode provided by VIM

Basically , Vim provided three main modes  Command mode, Insert mode and Visual mode.

The Command mode :

By default, the Vim editor is first launched in command mode. In this mode, key-presses are inactive, and a user cannot insert text or modify the file. However, you can navigate up and down, left and right, using the following keys:

– Moves up one row. (Equivalent of Arrow up key )

j – Moves down one row. (Equivalent of Arrow down key )

l – Navigates one character to the right or moves forwards. (Equivalent of Arrow right key)

h – Navigates one character to the left or moves backward. (Equivalent of Arrow down key )

You can also prefix the keys with a numeric letter to move up or down a certain number of rows or move forward and backward a certain number of characters. For example,

6k – moves up 6 rows

4j – Moves down 4 rows

The Insert mode :

This mode allows you to type in text and make changes to a text file as you deem fit. The insert mode can be accessed from the command mode by pressing the following keys.

The ‘i’ key ( insert ) allows you to insert a character at the cursor’s current position.

The ‘a’ key ( append ) – This moves the cursor one character to the right and gets you to insert mode.

The ‘o’ key – This creates a new line below the current row and switches to insert mode.

The Visual mode :

The visual mode is usually used to highlight text, similar to clicking and dragging with a mouse. To start making a text selection, simply type ‘v’ then leverage the arrow keys to highlight text.

Perform basic search operation in vim

To search text, you need to be in command mode. If you are in insert mode, simply press the ‘ESC’ key.

To perform a basic search of the string or text that you want, move to the beginning of the file and simply press the forward-slash ( / ) key. Then type the search string and press ENTER on the keyboard to start searching.

The forward-slash ( / ) key performs a forward search. It searches for the string or pattern from the current cursor position right up to the end of the file. To search for the next pattern, simply press the letter n on the keyboard.

To search backward, press the question mark symbol ( ? ), type the search string, and press ENTER on the keyboard. This searches the string from the current cursor position to the start of the file.

Search a complete word

To search for a complete word, begin by pressing the / or? Symbol. After that, type the \< symbol to mark the beginning of the word to be searched then /> to signify the end of the search word. Then finally, hit ENTER to commence the search.