Jump to content
  • Recently Browsing

    • No registered users viewing this page.

Linux Anybody?


Recommended Posts

Did you know?

 

history or fc -l commands can show your bash command line history or recall the history stored in ~/.bash_history file. You can make history to ignore the commands if it begin with a space:

w

history

fc -l

 

## run who command with a space ##

export HISTIGNORE="[ \t]*"

who

history

 

The HISTIGNORE shell variable controls which command lines should be saved (i.e. ignored) on the history list. To ignore duplicate commands in history, enter:

export HISTIGNORE="&"

 

You can define a colon-separated list of patterns to ignore ls command, duplicate commands, and ignore the commands if it begin with a space, enter:

export HISTIGNORE="ls:&:[ \t]*"

history

ls

date

date

cal

history

 

As a sys admin you may want to ignore the frequently used commands such as - ls, pwd, cd, mount, umount, clear, exit, and much more from your history.

export HISTIGNORE="ls:&:[ \t]*:cd:mount:umount:clear:exit:pwd:date"

 

See bash man page for more info:

man bash

help history

Link to comment

Simple script to list all active and system users.

 

------------------------[cut]------------------

#!/bin/bash

_l="/etc/login.defs"

_p="/etc/passwd"

 

## get mini UID limit ##

l=$(grep "^UID_MIN" $_l)

 

## get max UID limit ##

l1=$(grep "^UID_MAX" $_l)

 

## use awk to print if UID >= $MIN and UID <= $MAX and shell is not /sbin/nologin ##

echo "----------[ Normal User Accounts ]---------------"

awk -F':' -v "min=${l##UID_MIN}" -v "max=${l1##UID_MAX}" '{ if ( $3 >= min && $3 <= max && $7 != "/sbin/nologin" ) print $0 }' "$_p"

 

echo ""

echo "----------[ System User Accounts ]---------------"

awk -F':' -v "min=${l##UID_MIN}" -v "max=${l1##UID_MAX}" '{ if ( !($3 >= min && $3 <= max && $7 != "/sbin/nologin")) print $0 }' "$_p"

 

-----------------------[stop]-----------------

Link to comment

To removal ALL the files and not any subdirectories in /dest type the following

find /dest -type f -delete

 

To removal only the files and ot any subdirectories in /dest type the following:

find /dest -maxdepth 1 -type f -delete

 

The -delete option will only work on the modern Unix like systems. For older systems try shell loops or pipes or pipes via xargs

find /dest -type f -print0 | xargs -I{} -0 rm {}

Link to comment
  • 2 months later...
  • 5 months later...
  • 4 years later...
  • 2 weeks later...
  • 4 weeks later...
  • 2 months later...

how much is the linux software

 

Free. (Feel free to choose wide variety of distros such as Ubuntu, Mint, Elementary, OpenSuse, Puppy, etc.)

 

Perfect for old computers (even modern computer) lightweight, easy to use (unlike before....bashing sudoing all the way).

 

Pero may ibang linux na may bayad, perfect for enterprise level (Red Hat, etc._

Link to comment
  • 7 months later...
  • 11 months later...
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...