w command in Linux with Examples

w command in Linux Provides a quick summary of every user logged into a computer.

The w command in Linux provides information about currently logged-in users and their activities. It displays details such as the user’s username, terminal, remote host, login time, idle time, and the current command or process they are running.

w command in Linux with Examples

On the man page, the describes it

  • w – Show who is logged on and what they are doing.
  • man w– More details information.

w command in Linux with Examples

$ w

Executing the w command without any options will display a summary of logged-in users along with their activities. The output will include the following columns:

  1. USER: The username of the logged-in user.
  2. TTY: The terminal name or pseudo-terminal associated with the user.
  3. FROM: The remote host or IP address from which the user is logged in. If the user is logged in locally, this field displays the abbreviation “localhost” or the IP address “127.0.0.1”.
  4. LOGIN@: The login time of the user.
  5. IDLE: The idle time, indicating how long the user has been inactive.
  6. JCPU: The total CPU time used by the user’s processes.
  7. PCPU: The CPU time used by the user’s current process.
  8. WHAT: The command or process currently being executed by the user.

Conclusion

a simple command in Linux. It is the most popular in-use terminal Linux who is logged on and what they are doing. The w command also provides additional options for customized output and filtering based on specific users or terminals.

You can refer to the w command manual (man w) for more information on these options. Thank you for reading the DevopsRoles page!

uptime command in Linux with Examples

uptime command is a measure of system reliability, expressed as the percentage of time a machine, typically a computer.

The uptime command in Linux is used to display how long the system has been running, as well as the average system load over a certain period of time.

Here’s how you can use the uptime command:

On the man page, the describes it

  • uptime – Tell how long the system has been running.
  • man uptime – More details information.

Uptime command in Linux with Examples

$ uptime

Executing the uptime command without any options will provide a summary of system uptime and load averages. The output will include the following information:

  1. The current time.
  2. How long the system has been running?
  3. The number of logged-in users.
  4. The system load averages for the past 1, 5, and 15 minutes.

Here’s an example output of the uptime command in Linux:

 19:32:51 up  1:23,  3 users,  load average: 0.10, 0.12, 0.15

In this example, the system has been running for 1 hour and 23 minutes. There are three logged-in users. The load averages represent the system’s workload over the past 1, 5, and 15 minutes, respectively. In this case, the load averages are 0.10, 0.12, and 0.15, indicating a relatively low system load.

Conclusion

uptime command is a simple command in Linux. It is the most popular in-use terminal Linux for Telling how long the system has been running.

The uptime the command does not offer additional options, as it is designed to provide a simple overview of system uptime and load averages. For more detailed information and system statistics, you can explore other commands like top, htop, or specialized monitoring tools.

Thank you for reading the DevopsRoles page!

passwd command in Linux with Examples

command is a tool on Linux operating systems used to change a user’s password.

The passwd command in Linux is used to change a user’s password. It allows users to set or modify their own passwords or, if executed with root privileges, change the password for any user on the system.

The syntax

passwd [options] [LOGIN]

In man page, the describe it

  • passwd – change user password
  • man passwd

passwd command in Linux with Examples

passwd huupv

To change another user’s password (as root):

sudo passwd <username>

Replace <username> with the username of the user whose password you want to change. Running the command with sudo and providing the username will prompt you to enter the new password for that user. Again, the characters won’t be displayed while typing.

It’s important to keep in mind that only the root user or users with appropriate privileges (e.g., members of the sudo group) can change other users’ passwords.

Additional options can be used with the passwd command to modify its behavior, such as:

  • -l or --lock: Locks the specified user account.
  • -u or --unlock: Unlocks the specified user account.
  • -S or --status: Shows the password status of the specified user account.

Conclusion

The passwd command is a simple command in Linux. It is the most popular in-use terminal Linux for changing passwords users. You can refer to the passwd command manual (man passwd) for more detailed information on its usage and available options. Thank you for reading the DevopsRoles page!

gzip command in Linux with Examples

gzip is a software application used for file compression and decompression. It is a common way of compressing files in Linux.

The gzip command in Linux is used to compress files. It reduces the size of a file or a group of files and creates a compressed file with the extension .gz.

Here are a few examples of how to use the gzip command:

The syntax gzip command

gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ...  ]

On the man page, the describes it

Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77).

gzip command in Linux with Examples

Creating a compressed file

[huupv@DevopsRoles ~]$ gzip filename.txt

Decompress a File Using the gzip Command

[huupv@DevopsRoles ~]$ gzip -d filename.gz

Decompress multiple compressed files

gzip -d file1.gz file2.gz file3.gz

The following details about gzip command in Linux.

man gzip

Compress multiple files

gzip file1 file2 file3

Keep the original file after compression or decompression

gzip -k filename
gzip -dk filename.gz

The -k option is used to keep the original file after compression or decompression. When compressing a file, the original file will be retained, and a compressed file will be created with the .gz extension. Similarly, when decompressing a file, the original compressed file will be retained, and a decompressed file will be created without the .gz extension.

Conclusion

gzip command is a simple command in Linux. It is the most popular in-use terminal Linux for file compression and

pwd command in Linux with Examples

command is the print working directory. It is one of the most frequently used Linux. like is cd or ls command.

The pwd command in Linux is used to print the current working directory. It displays the absolute path of the current directory where you are located within the file system.

The syntax pwd command

pwd [Option] ...

On the man page, the describes it

Print the full filename of the current working directory.

pwd command in Linux with Examples

The full PathName of the current working directory.

[huupv@DevopsRoles ~]$ cd /etc/nginx
[huupv@DevopsRoles nginx]$ pwd
/etc/nginx

Use the -P option to display the physical path:

pwd -P

Use the -L option to display the logical path:

pwd -L

Print the current directory with a symbolic link indicator:

pwd -P -L

By combining both the -P and -L options, the pwd the command will display the physical path and indicate any symbolic links present in the path.

Conclusion

These are some examples of using the pwd command in Linux. The command is useful for verifying your current directory or capturing it for use in shell scripts or other commands. pwd command is a simple command in Linux. It is the most popular in-use terminal Linux. Thank you for reading the DevopsRoles page!

Fixing ansible python broken pipe for RHEL Centos 5

Introduction

In this tutorial, How to fix run ansible “[Errno 32] Broken pipe\r\n”. I have enabled the EPEL repositories and installed the required dependencies for Python. Running Ansible on RHEL/CentOS 5 can sometimes lead to a broken pipe error. This guide provides a detailed solution to this issue, ensuring your automation processes run smoothly fix ansible python broken pipe.

The Problem

When using Ansible with Python on RHEL/CentOS 5, you might encounter a broken pipe error. This occurs due to compatibility issues between the versions of Python and Ansible. The error message typically looks like this:

Ansible python broken pipe running error

"changed": false,
   "module_stderr": "",
   "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible-tmp-1546842879.5-134879756384147/setup.py\", line 133, in ?\r\n    exitcode = invoke_module(module, zipped_mod, ANSIBALLZ_PARAMS)\r\n  File \"/tmp/ansible-tmp-1546842879.5-134879756384147/setup.py\", line 38, in invoke_module\r\n    (stdout, stderr) = p.communicate(json_params)\r\n  File \"/usr/lib64/python2.4/subprocess.py\", line 1050, in communicate\r\n    stdout, stderr = self._communicate_with_poll(input)\r\n  File \"/usr/lib64/python2.4/subprocess.py\", line 1113, in _communicate_with_poll\r\n    input_offset += os.write(fd, chunk)\r\nOSError: [Errno 32] Broken pipe\r\n",
   "msg": "MODULE FAILURE",
   "rc": 1
}
       to retry, use: --limit @/nfs/playbooks/ansible-server/apache-server.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
webserver01         : ok=0    changed=0    unreachable=0    failed=1

My Ansible uses Python 2.6 and a remote server is a Virtual Machine OS Centos 5 use Python 2.4

After you install Python 2.6 on the remote server ( Centos 5). Then configure in the PATH for Python 2.6

For example, In my configuration in PATH as below

$ echo $PATH
/usr/local/bin:/bin:/usr/bin
$ which python
/usr/bin/python

Configure symbolic link for Python 2.6 on the remote server Centos 5

$ ll /usr/bin/ | grep python
$ ln -sf  /usr/bin/python26 /usr/local/bin/python

With that:

  • python 2.6 is in “//local/bin” *which is before “//bin” in the PATH
  • python 2.4 is in “//bin

And both are in the PATH

And you running the ansible-playbook command again.

FAQs

Q: Why do I need to update Python? A: The default Python version on RHEL/CentOS 5 is outdated and incompatible with newer Ansible versions, causing the broken pipe error.

Q: Can I use a different Python version? A: Yes, you can use any compatible Python version, but Python 2.7 is recommended for compatibility.

Q: What if I still encounter issues? A: Ensure all steps are followed correctly. Check the Ansible and Python versions, and verify the ANSIBLE_PYTHON_INTERPRETER path.

Conclusion

Fixing the Ansible Python broken pipe issue on RHEL/CentOS 5 involves updating Python, creating a virtual environment, installing Ansible in that environment, and configuring Ansible to use the correct Python interpreter. By following these steps, you can ensure the smooth operation of your Ansible automation tasks on older systems.

Through the article, you can use Fixing Ansible Python broken pipe for RHEL Centos 5. I hope this will be helpful for you. For more details, refer to the Ansible tutorial.

Git merge development branch to master branch

Introduction

In the world of software development, Git is a vital tool for version control, enabling teams to collaborate efficiently. One of the most common Git operations is merging a development branch into the master branch. This process ensures that the latest changes from the development branch are incorporated into the stable master branch. In this guide, we’ll cover everything you need to know about how to Git merge development branch to master branch, including best practices, conflict resolution, and real-world examples.

Understanding Git Branches

What Are Git Branches?

Git branches allow developers to work on different features, bug fixes, or experiments without affecting the stable codebase. The master branch (or main, as renamed in newer Git versions) serves as the main production branch, while the development branch is used for active feature development and testing.

Why Merge Development Branch to Master?

  • Integrate new features: Ensure tested features are available in production.
  • Maintain a clean codebase: Keep a structured development workflow.
  • Improve collaboration: Merge approved code into the main branch.
  • Reduce conflicts: Regular merges prevent large, conflicting changes.

Steps to Merge Development Branch to Master Branch

Step 1: Switch to Master Branch

Before merging, ensure you are on the master branch.

 git checkout master

Alternatively, for newer Git versions:

 git switch master

Step 2: Update Master Branch

Before merging, update the master branch with the latest changes from the remote repository to prevent conflicts.

 git pull origin master

Step 3: Merge Development Branch

Run the merge command to integrate the development branch into the master branch.

 git merge development

If there are no conflicts, the merge will be successful.

Step 4: Resolve Merge Conflicts (If Any)

If there are conflicts, Git will prompt you to resolve them manually. Open the conflicting files, edit them as needed, and mark them as resolved.

 git add <conflicted-file>
 git commit -m "Resolved merge conflicts"

Step 5: Push the Merged Changes

Once the merge is complete, push the updated master branch to the remote repository.

 git push origin master

Best Practices for Git Merging

1. Keep Development Branch Updated

Regularly pull changes from the master branch into the development branch to minimize conflicts.

 git checkout development
 git pull origin master

2. Use Feature Branches

Instead of merging directly to the development branch, create separate feature branches and merge them into development before merging development into master.

 git checkout -b feature-branch

3. Test Before Merging

Run tests to ensure that the merge doesn’t introduce bugs.

 npm test   # Example for JavaScript projects

4. Use Pull Requests

For team projects, use pull requests (PRs) to review code before merging.

5. Avoid Merge Conflicts

Regularly pull changes and communicate with your team to prevent conflicts.

Advanced Git Merge Scenarios

Merging with a Rebase

Instead of a merge, you can use rebase to maintain a linear history.

 git checkout development
 git rebase master
 git checkout master
 git merge development

Squash Merging

Squash commits before merging to keep the history clean.

 git merge --squash development
 git commit -m "Merged development branch with squash"

Aborting a Merge

If you encounter issues, you can abort the merge and reset.

 git merge --abort

Frequently Asked Questions (FAQs)

1. What is the difference between git merge and git rebase?

  • git merge creates a new commit combining both branches.
  • git rebase moves the development branch commits on top of the master branch.

2. What happens if there is a merge conflict?

Git will notify you of conflicts, and you must manually resolve them before completing the merge.

3. How can I undo a merge?

If a merge was completed but needs to be undone:

 git reset --hard HEAD~1

Note: This will erase uncommitted changes, so use with caution.

4. How often should I merge development into master?

It depends on your workflow, but ideally, after features are fully tested and approved.

5. Should I delete the development branch after merging?

If the development branch is no longer needed, delete it to keep the repository clean:

 git branch -d development
 git push origin --delete development

External Resources

Conclusion

Merging the development branch into the master branch is a crucial step in maintaining a clean and organized Git workflow. By following best practices such as updating branches regularly, using feature branches, and resolving conflicts proactively, you can ensure a smooth and efficient development process. Mastering Git merge techniques will help you collaborate effectively with your team and maintain a high-quality codebase. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Oracle v$system_parameter: A Guide for Database Administrators

Introduction

Discover how to effectively query the Oracle v$system_parameter. You’ll learn essential SQL commands to access and manage system parameters that control various Oracle database functions.

This guide is ideal for Oracle DBAs who need to monitor or adjust system settings for optimized database performance. Gain insights into best practices for querying and interpreting the values of critical system parameters in Oracle.

  • Oracle v$system_parameter: Displays system-wide parameter settings for the entire database instance.
  • Oracle v$parameter: Shows parameter values specific to the current session, allowing session-specific adjustments.
  • Key Differences:
    • Scope: v$system_parameter is instance-wide, while v$parameter is session-specific.
    • Usage: Understanding the difference helps in effective database management, optimizing both system stability and session flexibility.

What does Oracle “v$system_parameter” mean?

Oracle’s v$system_parameter is a dynamic performance view that provides information about the instance-level parameters of an Oracle database. It allows database administrators to view the current settings of various configuration parameters, which are essential for tuning and maintaining the database.

To check the values of these parameters, you need to log in to the Oracle database as a user with SYSDBA privileges and query the v$system_parameter view.

Step by step: Oracle v$system_parameter

Step 1: Log in and connect to the database as “SYSDBA“.

[huupv@devopsroles ~]$ sudo su - oracle
[oracle@devopsroles ~]$ sqlplus "/as sysdba"

Step 2: Check the value of a specific parameter

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'db_block_size';

The output will look like this:

NAME                 VALUE
-------------------- -----
db_block_size        9100

Step 3: Repeat the above query for other parameters:

To check value “db_cache_size” in Oracle Database.

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'db_cache_size';

To check the value of the java_pool_size parameter:

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'java_pool_size';

To check value “nls_language” in Oracle Database.

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'nls_language';

Check value “processes” in the Oracle Database.

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'processes';

To check the value “shared_pool_size” in Oracle Database.

SYS@DEVOPSROLES > SELECT name, value FROM V$SYSTEM_PARAMETER where name = 'shared_pool_size';

By querying the Oracle v$system_parameter view, you can easily obtain the current settings of various parameters, which is crucial for database administration and tuning.

Conclusion

the article on querying “v$system_parameter” in Oracle, it is essential to understand the power and significance of system parameters in managing and optimizing Oracle database environments.

This guide offers a comprehensive look at how to access and manipulate these settings, providing database administrators with the knowledge needed to ensure efficient database operation.

For further mastery of Oracle system parameters, continue exploring and experimenting with different queries and settings. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Linux command tips and tricks

Introduction

In this tutorial, I system admin. Linux the essential for DevOps Roles.

Begin with an engaging introduction that explains the importance of mastering Linux commands for DevOps professionals. Highlight how these commands enhance productivity and streamline operations in a Linux environment.

Linux command tips and tricks

How to return to the previous directory

$ cd -

The display headers and footers in FileName.

$ cat filename | sed -e '$d' | awk 'NR > 1 {print}'

Search files under arbitrary directories

$ find ./ -name '*'|xargs grep 'devopsroles.com'

Empty the file.

$ cat /dev/null > filename.txt

Move to thereafter create the folder

$ mkdir dir_name ; cd $_

To count the number of files in any directory.

$ ls -F |grep -v / |wc -l

or count the number of folders in any directory.

$ ls -F |wc -l

Convert all extensions

$ for filename in *.txt; do mv $filename ${filename%.txt}.txt.old; done

To create serial number files.

$ touch foo_{1..4}.csv
$ touch {A..X}.csv

Delete “.DS_store” in bash

$ find . -name '.DS_Store' -type f -ls -delete

How to delete the last slash of the path.

$ MYDIR=${MYDIR%/}

Extract processes that use a lot of physical memory

$ ps aux | sort -n -k 6 | tail -n 10

Find processes with high CPU utilization

$ vmstat 1 | awk '{print strftime("%y/%m/%d %H:%M:%S"), $0}

lsof command list of ports in Listen

$ lsof -Pan -i tcp -i udp

Generate random passwords using the head command and tr command.

$ head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''

Extract a character string

$ echo 'devopsroles.com' | awk '{print substr($0, 2)}'

the mount command the display formatting with column

$ mount | column -t

To See CPU utilization per user

$ ps aux | awk  '{if (NR> 1) {p [$1] +=$3; n [$ 1] ++}} END {for (i in p) print p [i], n [i], i }'

How much RAM is installed on this system?

[huupv@huupv devopsroles]$ sudo dmidecode -t 17 | grep "Size.*MB" | awk '{s+=$2} END {print s / 1024 "GB"}'

Awk command line

Character count (wc – c)

$ awk '{n+=length($0)} END{print n}' filename

Word count (wc – w)

$ awk '{n+=NF} END{print n}' filename

Row count (wc – l)

$ awk 'END{print NR}' filename

Display from specified line to specified line

$ awk 'NR==3,NR==10'

Kill bulk by process name

$ kill $(ps aux | grep  "jenkins" | awk '{print $2;}')

Conclusion

Throughout this article, we’ve explored various Linux command tips and tricks. I hope you find these insights useful for your tasks. Thanks for visiting the DevopsRoles page.

Mastering Oracle query tablespace: A Comprehensive Guide for DBAs

Introduction

In this guide, you’ll learn how to efficiently query Oracle tablespaces using SQL commands. This guide covers essential techniques for monitoring tablespace size, available space, and differentiating between various types of tablespaces. This practical approach aims to enhance database management skills for Oracle administrators.

  1. What is Oracle SQL Tablespace?
    An overview of tablespaces in Oracle databases, explaining their purpose and types.
  2. How to Query Oracle Tablespace?
    Basic SQL queries to retrieve information about tablespaces, including size and contents.
  3. Check Tablespace Usage Percentage in Oracle
    Methods to calculate the usage percentage of tablespaces to monitor efficiency and plan for scaling.
  4. Oracle Query Tablespace Usage
    Advanced querying techniques to analyze tablespaces’ performance and optimize storage management.

Step-by-Step: Guide to Oracle Query Tablespace

How does a query check tablespace size, free space, and Big file vs small file SYSTEM tablespace? The following statement is below

SELECT tablespace_name,
  SUM(bytes)/1024/1024 AS mb
FROM
  ( SELECT tablespace_name, bytes FROM dba_data_files
  UNION ALL
  SELECT tablespace_name,bytes FROM dba_temp_files
  )
WHERE tablespace_name='SYSTEM'
GROUP BY tablespace_name;

Sample Output

TABLESPACE_NAME                    MB
-------------------- ----------------
SYSTEM                          2,048

To query tablespace “SIZE EXTEND, BIG_SMALL_FILE, BLOCK_SIZE” in Oracle.

SELECT dt.tablespace_name tablespace_name,
  SUBSTR(ddf.file_name,0, instr(ddf.file_name, '/', -1, 1) - 1) AS placement_directory,
  SUBSTR(ddf.file_name, instr(ddf.file_name, '/',   -1, 1) + 1) AS file_name,
  ddf.bytes                                         /1024/1024  AS mb,
  ddf.autoextensible,
  DECODE (dt.bigfile,'NO','SMALL','YES','BIG') AS BIG_SMALL_FILE,
  dt.block_size block_size
FROM
  (SELECT tablespace_name, file_name, bytes,autoextensible FROM dba_data_files
  UNION
  SELECT tablespace_name, file_name, bytes,autoextensible FROM dba_temp_files
  ) ddf,
  (SELECT tablespace_name, block_size,bigfile FROM dba_tablespaces
  ) dt
WHERE dt.tablespace_name = ddf.tablespace_name
AND dt.tablespace_name   = 'SYSTEM';

Sample Output

TABLESPACE_NAME
--------------------
PLACEMENT_DIRECTORY
------------------------------------------------------------------------------------------------------------------------------------
FILE_NAME                                                                            MB AUTOEXTEN BIG_SMALL_FILE  BLOCK_SIZE
---------------------------------------------------------------------- ---------------- --------- --------------- ----------
SYSTEM
/mnt_nfs/dbdata/mydata
system02.dbf                                                                      2,048 NO        SMALL                 9192

Conclusion

This article provides a comprehensive guide to Oracle query tablespaces for size, auto-extension, file types, and block sizes. By mastering these queries, you can effectively monitor and optimize your Oracle database storage. Continuous monitoring and analysis will ensure that your database runs efficiently and remains scalable. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Devops Tutorial

Exit mobile version