Skip to main content

Posts

Showing posts with the label Linux for noob

How to display Adobe PDF in full screen window

How to display a PDF using Adobe reader or Adobe editor in full screen window?

How to display a PDF in presentation mode just like a PowerPoint?

Displaying a PDF in full screen mode or in a borderless window with just the contents shown in the screen is quite simple and straight forward.

Why do you need to show a PDF in presentation mode?

One reason I have in mind is if you only have a PDF in hand that is neatly arrange and beautifully crafted and you need to present.

Well, if you will be in the same shoes. Just press Ctrl + L.

Yes, Ctrl key + Letter "L". Or ctrl + l key.

The PDF will be in presentation mode and every click of the  mouse it will go to the next page.

To exit or to return to the normal view window, just press "esc" key.

Ctrl + L key, works in Adobe 9 to the latest version.


Cheers..till next time…

================================ Free Android Apps:
Click on links below to find out more:
Catholic Rosary Guide  for Android:
https://play.google.com/store/apps…

Add a user in command line in Windows and Linux

How to add a user via command line in Windows and Linux?

Adding a user whether in Linux or Windows requires the user have rights to create.

In Windows you must be a member of the administrator or other groups who has the rights to create a user.

In Linux you must be a root or either a member of the sudoers depending on what distro you are using.

In Windows to create  a local user in a Windows client operating system such as Windows 7 or Windows 10.

A one liner command can be issued to create a local user, using the command prompt Window at an elevated mode or administrator mode.

At the command prompt type:

Net user  "username" "password" /add

Net user  << this should be type like that it’s part of the command syntax while username and password, can be any data and of course /add is needed meaning the command is adding a user to the system.

Example: net user spiderbond 007-homeSp!dey /add

Command will add a user name called spiderbond and the password is 007-…

Linux list folders recursively

To list all folders on the root directory, type:
  ls -d /*
Sample Output:
/bin     /dev   /smsbackup  /lost+found  /mnt  /proc  /selinux  /tmp /boot    /etc   /lib        /media       /net  /root  /srv      /usr /cgroup  /home  /lib64      /misc        /opt  /sbin  /sys      /var
To list all folders on the current folder, one level depth only; type:
[xxx@mx var]$ ls -d */
Sample Output:
account/  cvs/    games/  local/  lost+found/  opt/       spool/  yp/ cache/    db/     gdm/    lock/  sms/        preserve/  tmp/ crash/    empty/  lib/    log/    nis/         run/       www/

List all folders and sub folders, 2 level depth or 2 level hierarchy; type:
[xxx@mx var]$ ls -d */*/
Sample Output:
cache/abrt-di/        lib/misc/        log/ConsoleKit/      run/portreserve/ cache/cups/           lib/mlocate/     log/cups/            run/rhsm/ cache/fontconfig/     lib/net-snmp/    log/sms/            run/saslauthd/ cache/foomatic/       lib/nfs/         log/gdm/             run/sepermit/ cache…

Use tar command to backup in Linux

tar or tape archive is a basic tool that every Linux user should know.

Its syntax is quite different from the traditional copy or move command.

Since tar works from a 'current working directory' perspective.

Traditional syntax for copy or move is source then the destination.

In tar, the syntax is the filename or the path where the backup will be save and the source or the folder to be backed up or archived.

Typing: man tar (at the terminal shows the following)

tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.

Basically, it's like the destination where the file will be saved and the source or the files that will be archived.

Here's a simple bash script that will append the time and date the tar file was executed to the filename of the tar file.

If the bash script is automated via cron, the filename of the tar file will include the date and time the cron executes the script.


#script begins

#!/bin/bash
NOW=$(date +%Y%m%d%H%M)
echo $NOW
tar -Pczvf   /mnt/o…

Bash check if folder exists

Simple bash script for beginners trying to get their hands wet on bash scripting.
The code below will ask for input and the input should be a string or a folder name.
The script will just do a basic ls and if the folder name is found it will show “The folder is found” or else the next echo statement is displayed.
Instead of simply displaying an echo command a function or another script can be called to execute a process further.
#!/bin/bash # This script will ask for a string or folder name and check whether it is present or not
echo "Enter folder name, followed by [ENTER]:"
read folder_name
ls | grep ^$folder_name && echo "The folder is found" || echo "The folder cannot be found" #Script ends
It’s a one liner evaluation, some sort an if then else in other programming languages, the && statement is executed if the evaluation is true, and if the evaluation is false the || is executed.
The read folder_name line, is the statement that will hold the inp…

Linux basic device utility tools

Knowing the devices in your computer is quite important in order to check what devices are installed or running in the computer
Getting to use Linux or starting to use it may seem daunting for others.
But Linux is awesome aside that its free and open source, in order to get used to it then you have to use it.
How to check installed USB drives or external USB devices in Linux?
How to check what graphic chipset or video chipset your computer is using in Linux?
How to check the audio chipset in your Linux system?
All these questions will pop-up once you start using Linux.
Or how would to check whether the inserted USB thumbdrive or an external USB drive is detected or not.
Well, some Linux distro provides a GUI interface to do it.
But the very basic way to check is to open via the Terminal window.
Or basically the command line in Linux.
ls - or list directory contents is the most basic way to learn on command line
ls will list the files and directories
To issue the commands below, open …

Linux bash script get folder size

Having an error, no space left on the device?
But you don't know which folder is consuming the most space?
Bash script below will get all the folder size and display the size for each folder.
How to use the script below?
Open your favourite terminal editor, vi, vim or other editor.
At terminal, type: vi dirfoldersize.sh
Copy and paste the code below to the editor.
Save the file.
Then make the script executable, chmod +x dirfoldersize.sh
Run the script by typing, ./dirfoldersize.sh
If everything goes well, you will get the folder size for each folder on the directory where the script runs. See sample output below.
=============== #code begins start copy below
#!/bin/bash curdir=$(pwd) compath="$curdir/dirlist.txt" ls -l | grep ^d | awk '{print $9}'  > $compath

while IFS= read -r var do

  foldersize=$(du -sh $var |awk '{print $1}')
  echo "$curdir/$var folder size: $foldersize"
done < "$compath"
#code ends, end copying from above line ======…

List completed cron jobs in Centos

Listing cron jobs or log files within a specific time frame is quite hard especially if the log or logs are quite a big file.

But of course, doing the lazy way but a smarter way is always a good option.

Use SED or stream editor.

In Centos the log is in: /var/log/cron

/var/log - path for the file
 cron - is the file that keeps the record for cron jobs, there is no filename extension

To check the logs within the 24 hours time, sed can do it easily and quickly.

Here's one line, time saver command to check the cron log file:

sed -n '/Mar 10 00:00:01/ , /Mar 11 00:01:01/p' /var/log/cron

To redirect the output to a file:

sed -n '/Apr 10 00:00:01/ , /Apr 11 00:01:01/p' /var/log/cron > cron24_hours.record.log

You can replace /var/log/cron with any other files as long as it follows the time format of Month, Day of the month and the time in HR:MM:SS format.


Download the free Linux Android App cheat sheet, see link below. It's free. Enjoy.



Cheers..till next time!

=======…

Linux bash script copy folders and files from list

In Linux special characters such as "#", "-" and other special characters cannot be access directly either by manual copy or via script. For example this path below it has the sharp "#" key:
/usr/dfiles/$line/Tasks/#msgs/
cp "/usr/dfiles/$line/Tasks/#msgs/*.eml" "/mnt/NAS/Tasks1/line/"
Even though the path is enclosed by quotation marks, Linux system will show "No such file or directory".

Since the system is unable to find the "#msgs" directory.

As a work around in this issue is to append "--" double dash before the cp command and everything will work fine.

So, this command below will work.

cp  -- "/usr/dfiles/$line/Tasks/#msgs/*.eml" "/mnt/NAS/Tasks1/line/"
Copying one folder is quite practical to do it by hand rather by script.
But if you are copying hundreds or thousands of folders, doing it manually is quite painful.
To copy hundreds or thousands of folders to another folder the pra…