Archive

Archive for the ‘how do I?’ Category

Load all available PowerShell Modules

January 12, 2016 Leave a comment

I’ve had to look this tip up a number of times, so here it is.

Say you are running PowerShell on a Windows server, however it does not automatically load all available modules and you need one for a specific script you’ve got.  Load all available PowerShell modules on a Windows server by running this command:

Get-Module -ListAvailable | Import-Module

From the “Hey, Scripting Guy! Blog.”  Thank you!

Advertisements
Categories: how do I?, windows Tags:

Deploy Node.js to Fedora 18

March 2, 2013 Leave a comment

Per github wiki for node.js, Fedora 19 will have node.js included.  However, to obtain node.js in Fedora 18, do the following:

sudo yum --enablerepo=updates-testing install nodejs npm

 

Grep through a unix directory with a long list of files

June 16, 2011 Leave a comment

Sometimes when attempting to grep through the files in a directory, there are so many files in the directory that grep returns an error indicating the argument list is too long.  Fix this by using xargs.

find ./ -print | xargs grep -l <your_string>

Categories: how do I?, solaris 10, useful

Count number of files in a unix directory

June 16, 2011 Leave a comment
ls -1 | wc -l
Categories: how do I?, solaris 10, useful

Add/view/delete an entry to iptables to enable Apache/VNCServer/FTP, etc.

April 28, 2011 Leave a comment

The default CentOS 5.6 firewall configuration does not allow Apache httpd traffic on port 80.  In order to open the port for utilization, a change must be made to the firewall configuration.

iptables -I INPUT -p tcp -m tcp ––dport 80 -j ACCEPT

To open a hole for VNCServer (running on display 20):

iptables -I INPUT -p tcp -m tcp ––dport 5920 -j ACCEPT

To open a hole for VNCServer (running on display 20) web base interface:

iptables -I INPUT -p tcp -m tcp ––dport 5820 -j ACCEPT

To display the openings you’ve created in your firewall:

iptables -L INPUT -n ––line-numbers

To remove a line entry from your iptables file (for example, entry #3):

iptables -D INPUT 3

Notes:

There are two dashes in front of parameters such as “––line-numbers” and “––dport.”

The iptables service must be saved, and restarted before changes take effect.

service iptables save

service iptables restart

manually add new user to Red Hat/Fedora/CentOS

April 19, 2011 Leave a comment

To manually add a new user to a  Red Hat/Fedora/CentOS intall which is utilizing shadow passwords:

As root

  • cp /etc/passwd /etc/passwd.bak (make a back-up copy of your password file)
  • cp /etc/shadow /etc/shadow.bak (make a back-up copy of your shadow password file)
  • cp /etc/group /etc/group.bak (make a back-up copy of your group file)
  • vipw  (to open passwd file in vi)
  • <shift> g  (to get to end of file)
  • a (append at end of cursor)
  • user01:x:501:501:User 01:/home/user01:/bin/bash  (add the new user)
  • :wq  (write file and quit vi)
  • A prompt will indicate that you are using shadow passwords, and do you want to edit the /etc/shadow now.  Answer: n
  • vi /etc/group  (to open group file in vi)
  • <shift> g  (to get to end of file)
  • a (append at end of cursor)
  • user01:x:501:user01 <enter>
  • admins:x:502:user01 (create a new group called admins and put user01 into it)
  • :wq  (write file and quit vi)
  • pwconv  (add the new entry from your passwd file into shadow password file)
  • passwd user01  (set the new user password)
  • (prompted twice for new user password)
  • mkdir /home/user01
  • cp /etc/skel/.* /home/user01 (copy all files from skel to new user home directory)
  • cp -r /etc/skel/.kde /home/user01
  • cp -r /etc/skel/.mozilla /home/user01
  • chown -R user01:user01 /home/user01  (Change the owner of user01 home directory to user01)
  • visudo -f /etc/sudoers
  • After root   ALL=(ALL)    ALL add new line and:  %admins   ALL=(ALL)    NOPASSWD: ALL  (this allows members of admins group to sudo as root, without a password.)
Categories: fedora, how do I?, linux, useful

Change run level on Red Hat/Fedora/CentOS

April 19, 2011 Leave a comment

Change the default run level on Red Hat/Fedora/CentOS distros to boot into server/console mode rather than GUI (from runlevel 5 to runlevel 3).

As root, edit /etc/inittab using vi or vim.  It should be somewhat self-explanatory, however make this change:

# id:5:initdefault:

id:3:initdefault:

Categories: fedora, how do I?, linux