Skip to main content

Posts

Showing posts with the label Ubuntu

Nano editor shortcut keys

Nano editor in Linux is quite handy when working with text files in terminal window. Here's some keystroke that is quite useful when using Nano or editing text file with Nano. Ctrl + i  is like pressing the "Tab" key Ctrl + y will   go to top of the current displayed window or the top of the current nano screen Ctrl + v will go to the end of the current displayed window or the end of the current nano screen Ctrl + m  will move current line below the current cursor position Ctrl  + d will delete empty line                or will delete tab spaces                or will delete a single character if the line has text on it Ctrl + k   will cut the current line or current line will be cut and copied to clipboard (like Ctrl + x in word document if the text is highlighted) Ctrl + u   will paste the line that was cut or whatever is on the clipboard (like Ctrl /+ v in word doc...

Bash save Linux command output to a variable

How to save the output of a command to a variable in Bash script? In Bash getting the output of a command line in terminal is sometimes necessary when doing Bash/Shell script. For example, if need to monitor a specific service whether it is installed, running or disabled. Getting the output of the command that checks the status of specific service is quite important, so the script will know on what to execute. If the specific output shows that the service has stopped then the script can decide to start the service, or if the output shows that a specific service or software is not installed then an option to install the software can be done. Here’s an example on how to save the status of a specific output to a variable using Bash. #!/bin/bash dcommand=$(systemctl status gdm.service) command_output=$(echo "$dcommand") str_running='Active: active (running)' if [[ "$command_output" == *"$str_running"* ]]; then   echo "It's the...

Linux find accessed and modified files

Finding accessed and modified files might be necessary at times to check or for audit purposes. If files kept in a folder or directory has been accessed or modified but should not be the case then something dubious is going on.  In Linux finding accessed and modified files can be done in a one liner command. find /home -type f -amin -60 || -mmin -60 -print Above command will find or show any files accessed within the last 60 minutes with the option "-amin" and it will show also the files modified within the last 60 minutes with the option "-mmin". A shell script can be created and further processing can be done when files are detected. The time can be adjusted if there's a need, but a more robust solution to check any accessed or modified files should be a file system watcher, but above command is quite helpful to check any activity that should not be occurring. Cheers..till next time!   ================================ Free Android Apps: Click  links below to f...

Samba set or change user password

Set, update or change a user password in Samba. If domain admin or user password that is set on samba needs to be updated. Open terminal then update using the command below:      smbpasswd -a     smbpasswd -a administrator After pressing enter, type the password twice to validate and confirm the password. If the user name or admin password has been updated on the Windows Active Directory, then the Samba password has to be updated as well. If the samba password is not updated then the client from the windows environment authenticating to samba will not be able to connect to samba shares. To dig more about smbpasswd check out link below: https://www.samba.org/samba/docs/man/manpages/smbpasswd.8.html -a This option specifies that the username following should be added to the local smbpasswd file, with the new password typed (type for the old password). This option is ignored if the username following already exists in the smbpasswd file ...

Ubuntu Calendar

I was mingling with my virtual box with Ubuntu installed. I found this calendar quite interesting and impressive. I don't know whether this can be viewed  via GUI, nevertheless it is still interesting since the data can be viewed using the terminal window with just the simple cat command. Here's the path: /usr/share/calendar Open a terminal and browse to the path above. cd  /usr/share/calendar Here's some of the calendar available, it's not a complete list. calendar.australia calendar.computer calendar.music View the calendar contents by typing the command below: cat calendar.computer Sample output from calendar.computer: 01/17     Justice Dept. begins IBM anti-trust suit, 1969 (drops it, January 8, 1982) 01/24     DG Nova introduced, 1969 01/25     First U.S. meeting of ALGOL definition committee, 1958 01/26     EDVAC demonstrated, 1952...