Skip to main content

Posts

Showing posts with the label Bash script

Create a new text file with content in Linux

Touch command in Linux will create an empty file in Linux command line. If no other parameters is specified whether a line will be inserted to the newly created file.
Cat command is for reading files via command line but it can also be used to create a file in Linux terminal window command line.
Cat command below will create a file called “test_comment.txt” and with the content or the line of “Hello World of Touch and Create File” on the file created.
Here’s the shell command:
cat  <( echo “Hello World of Touch and Create File”)  >  test_comment.txt
Note that there is no space between “<(“, if there is a space then the command will not work as expected.
Touch command to create a new file and also insert a new line or insert a string on the newly created file.
Here’s the shell command:
touch touch_file_comment.txt; echo “Hello World of Touch, insert this line.” >  touch_file_comment.txt

Basically, the command executes two commands separated by “;” semi-colon. The first part is to cr…

How to copy a line using Nano editor?

Copying in Nano needs a few keys to copy and paste. 
Copy and paste goes hand in hand, there’s no point to copy if you cannot paste.
So, how to copy using Nano editor in Linux?
To copy in Nano editor , a few key strokes are needed.
On the beginning of the line that will be copied press:
ctrl + 6 (to set a mark)
Press “end” key or use right arrow to go to the end of the line.
If multiple lines are to be copied used down arrow to select the lines.
After selecting the line or lines to be copied, press:
alt + 6 (to set unmark and all line/s selected is copied to the clipboard already.
To copy the line or lines, position the cursor where the line/s will be copied and press:
ctrl + u (this will paste the line/s or whatever is on the clipboard)

That’s it, quite a few key strokes to remember but if you’re in a command line or in Putty; then these key combination to copy and paste in Nano is really a life saver.

Cheers..till next time. :)


================================ Free Android Apps:
Click  link…

PowerShell check access or folder permissions

In an Active Directory domain, one of the common issues is folder permissions. Of course, permission must be restricted as much as possible. In order, confidential data or things that only a group of people will know, is not made available to everyone.

Employee salaries on a network share made available to everyone, will cause some employees to be disheartened. Such data, the access or folder permission should be checked properly.
One way to check a folder permission is to assume or login as a certain user that is not supposed to have access to such data and checked whether the data can be viewed or not.
Aside from restricting permissions for confidential data; data supposed to be accessed by everyone but some user’s complaint that they are unable to access then this will also cause some problem and may end up not being productive for the users.
One way to check is to go to the user’s workstation and verify whether the user is unable to access. This kind of issue is not hard to solve…

PowerShell get screen resolution

Check screen resolution of the monitor using PowerShell.
Get-WmiObject-Query"Select * from Win32_desktopmonitor"-Namespace'Root\CIMV2'|selectname,screenheight,screenwidth
Sample output:
namescreenheight screenwidth ---------------- ----------- Default Monitor Generic PnP Monitor 10801920

To check remote PCs, use the code below, of course proper credentials is required.
Invoke-Command-ComputerName192.168.1.20-ScriptBlock { Get-WmiObject-Query"Select * from Win32_desktopmonitor"-Namespace'Root\CIMV2'|selectname,screenheight,screenwidth }
Some application requires or either work properly when a particular screen resolution is properly set or configured.
To get more details like video processor, driver version and driver date use the code below. Updating drivers is quite important as it will improve device performance and other update features.
Get-WmiObject-Query"Select caption,driverdate,driverversion,videoprocessor from Win32_videocontroller"-N…

PowerShell check sound devices

PowerShell code below will list the names of the sound devices and its status on the system.
The status might show OK, I believe this refers to the driver installation but if some settings are misconfigured that will be another issue.
Here’s the code:
Get-WmiObject-Query"Select * from Win32_sounddevice"-Namespace'Root\CIMV2'

Sample output:
ManufacturerNameStatus StatusInfo ---------------------- ---------- Intel(R) Corporation Intel(R) Display AudioOK3 (Generic USB Audio)USB Audio DeviceOK3 RealtekRealtek High Definition Audio OK3

Cheers..till next time. :)


================================ Free Android Apps:
Click  links below to find out more:
Excel Keyboard guide: https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide

Heaven's Dew Fall  Prayer app for Android :
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide  for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytess…

PowerShell GUI with buttons, textbox and combobox

GUI makes life easier, but of course command line has a power of its own.
How to add a form in PowerShell with Buttons, TextBox and ComboBox?
Adding GUI forms in PowerShell must be done manually by code.
It’s not that hard, you just need to love PowerShell and see what it can do to automate IT administration and makes your life easier.
Anyway, code below introduces how to add GUI to PowerShell and it also illustrates how to make use of those GUI buttons and send a command to remote computers.
Code to add buttons, textbox and combobox in PowerShell, and how to execute a command after the button is clicked.
#initialize the main form $form=new-objectWindows.forms.form $form.text ="Server Selection Form"
$form.minimumSize =New-ObjectSystem.Drawing.Size(600,300) $form.maximumSize =New-ObjectSystem.Drawing.Size(600,300)
#add a button to the form $button=new-objectwindows.forms.button $button.text ="Close Me"
#action that the button will execute after it has been clicked