Posts

Showing posts with the label Unix

Featured Post

15 Python Tips : How to Write Code Effectively

Image
 Here are some Python tips to keep in mind that will help you write clean, efficient, and bug-free code.     Python Tips for Effective Coding 1. Code Readability and PEP 8  Always aim for clean and readable code by following PEP 8 guidelines.  Use meaningful variable names, avoid excessively long lines (stick to 79 characters), and organize imports properly. 2. Use List Comprehensions List comprehensions are concise and often faster than regular for-loops. Example: squares = [x**2 for x in range(10)] instead of creating an empty list and appending each square value. 3. Take Advantage of Python’s Built-in Libraries  Libraries like itertools, collections, math, and datetime provide powerful functions and data structures that can simplify your code.   For example, collections.Counter can quickly count elements in a list, and itertools.chain can flatten nested lists. 4. Use enumerate Instead of Range     When you need both the index ...

Unix Special Keys That Improve Productivity

Image
Shared the UNIX terminal shortcut keys. These special keys you can use to stop the program processing, or resume it. An example of a UNIX special key and its use. Special Keys in UNIX much useful to take action when something happens. A scenario where you made some mistake in the input command and you need to stop the further process. Then you can use the CTRL+C command. It is equal to the DELETE command. Unix Keyboard Shortcuts or Special Keys. RETURN key  The RETURN key signifies the end of a line of input. On any terminal, RETURN has a key of its own, or return may be typed by holding down the control key and typing a 'm'. CTRL-m Key Hint: Ctrl-m command is equal to RETURN key in Unix systems DELETE Key The DELETE key stops a program/command immediately, without waiting for it to finish. DELETE can be achieved equivalently with ctrl-c. Hint: Ctrl-c Command you can use to interrupt the process. CTRL-s Key Ctrl-s pauses the output and the program is suspended until you sta...

10 Top Unix Disk Space Quiz Questions

Image
I have listed 10 top Quiz questions on UNIX disk space. These questions help you to understand about disk-related concepts quickly. Unix Disk Space QUIZ Questions. Below listed 10 quiz questions help you to know the disk-space related concepts. 1. All devices are considered as files in Unix. Yes 2. All device files are stored in /etc or in its subdirectories. No 3. CD-ROM is a character device. No 4. The printer is a character device. Yes 5. The minor number represents the type of device. No 6. The dd command is used for copying data from one medium to another. Yes 7. The term bs in the dd command stands for block size. Yes 8. The du utility displays complete information about the usage of disk space by each file and directory. Yes 9. By default, the du command displays information in terms of 1024-byte blocks. No 10. The df command reports only the free disk space of the file system installed on our machines. Yes Keep Reading Top vi Editor Commands for Ubuntu

Vi Editor to Quit use Esc and Colon

Image
Here are vi editor commands you can use to quit from Vi editor with or without saving your work. These are useful to use in day-to-day work. w => To Save Your Work q => To Quit wq => To Save and Quit q! => To quit without saving vi editor also called Visual editor in terms of Unix or Linux or Ubuntu Operating systems. Since all are the same UNIX flavor, and UNIX is the mother of all these operating systems. Recently many of my friends asked to share some daily use vi editor commands . I am sharing those for your quick reference. 6 Top vi Editor Commands 1. How to Edit a file? vi filename This is the first command to use for editing a file. 2. A command to Repeat Previous Command? Use the  UP arrow to repeat the previous command. 3. How to Insert data? Use insert command to over-type data. 4. How to Save File? Press Esc then :w 5. How to Save and Quit (Exit)? Press Esc then :wq 6 How to quit without Save? Press Esc then :q!

10 Top Differences Between Unix and Linux

UNIX It is an operating system which was first developed in the 1960s and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops, and laptops. UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no windows interface available, for example, in a telnet session. The kernel - The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls. As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file c...

19 Top Unix File Scenario Commands

Image
ETL developers main task is to browse various flat files before they start testing. File browsing in UNIX is tricky. If you know right command to do it you can save a lot of time. These 19 top UNIX files commands useful to use in your project. In UNIX a file normally can have Header, Detail and Trailer. There are scenarios where you need only details without header and Trailer, and need only recent one record, and you need to skip some records from the input files. So for all the File based scenarios, I have given useful UNIX commands.   1). How to print/display the first line of a file?  There are many ways to do this. However the easiest way to display the first line of a file is using the [head] command.  $> head -1 file. Txt If you specify [head -2] then it would print first 2 records of the file.  Another way can be by using [sed] command. [sed] is a very powerful text editor which can be used for various text manipulation purposes like this.  ...

Unix: How to Write Shell Script Using vi Editor

Image
Stockphotos.io When you login into UNIX, you are first in the home directory: $/home: Then you can issue $/home: cd jthomas Then you come to your own directory: $/home/jthomas: How to write your first script: $/home/ jthomas : vi test.sh Here, you can write your script. The first line in the script is: #!/bin/ksh - It denotes which shell you are going to use. Example: $vi test.sh  #!/bin/ksh  ################################################### #  Written By: Jason Thomas # Purpose: This script was written to show users  how to develop their first script  ################################################### # Denotes a comment root daemon bin sys adm uucp nobody lpd How to run a script $ sh test.sh Also read:  The complete list of UNIX basic commands

UNIX Shell script to know input is integer or not

Image
(Apply hot Unix jobs) Unix Shell script to know input is integer or not. $vi prg1 clear echo "enter a number" read x y='expr $x % 2' if test $y -eq 0 then echo "Number is even" else echo "Number is odd" fi Running Script $sh prg1 enter a number 11 Number is odd $sh prg1 enter a number 12 Number is even

UNIX Shell Scripting and Job Scheduling

Shell scripting and job scheduling are two major tasks for any UNIX developer. I am presenting here essential commands that need for any developer. Shell Scripts commands Shell script basics Variables in shell scripts Kornshell arithmetic  Commands for scripts Flow control, tests, and expressions Making Scripts Friendlier Functions Pipes and Shell Scripts Scripts with awk and/or sed Job Scheduling commands bg and at cron Read here