![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
This is how to How to call a shell script from python code
To call a shell script from Python code, you can use the subprocess
module, which is a part of the Python standard library. The subprocess
module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
import subprocess
# Call the script using the `call` function
subprocess.call([“/path/to/script.sh”])
# Call the script and pass arguments to it
subprocess.call([“/path/to/script.sh”, “arg1”, “arg2”])
# Call the script and store the output in a variable
output = subprocess.check_output([“/path/to/script.sh”])
print(output)
In this example, the call
function is used to execute the shell script and wait for it to complete. The check_output
function is used to execute the shell script and store the output in a variable.
You can also use the Popen
class from the subprocess
module to execute the shell script in a separate process and communicate with it in real-time.
import subprocess
subprocess.call(['sh shell_script.sh arguments'])
or
import sys, os
os.system("sh shell_script.sh arguments")
Output Example
Basic Gotcha Linux Questions for IT DevOps and SysAdmin Interviews
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
Some IT DevOps, SysAdmin, Developer positions require the knowledge of basic linux Operating System. Most of the time, we know the answer but forget them when we don’t practice very often. This refresher will help you prepare for the linux portion of your IT interview by answering some gotcha Linux Questions for IT DevOps and SysAdmin Interviews.
Latest Linux Feeds
I- Networking:
- How many bytes are there in a MAC address?
48.
MAC, Media Access Control, address is a globally unique identifier assigned to network devices, and therefore it is often referred to as hardware or physical address. MAC addresses are 6-byte (48-bits) in length, and are written in MM:MM:MM:SS:SS:SS format. - What are the different parts of a TCP packet?
The term TCP packet appears in both informal and formal usage, whereas in more precise terminology segment refers to the TCP protocol data unit (PDU), datagram to the IP PDU, and frame to the data link layer PDU: … A TCP segment consists of a segment header and a data section. - Networking: Which command is used to initialize an interface, assign IP address, etc.
ifconfig (interface configuration). The equivalent command for Dos is ipconfig.
Other useful networking commands are: Ping, traceroute, netstat, dig, nslookup, route, lsof - What’s the difference between TCP and UDP; Between DNS TCP and UDP?
There are two types of Internet Protocol (IP) traffic. They are TCP or Transmission Control Protocol and UDP or User Datagram Protocol. TCP is connection oriented – once a connection is established, data can be sent bidirectional. UDP is a simpler, connectionless Internet protocol.
The reality is that DNS queries can also use TCP port 53 if UDP port 53 is not accepted.
DNS uses TCP for Zone Transfer over port :53.
DNS uses UDP for DNS Queries over port :53. - What are defaults ports used by http, telnet, ftp, smtp, dns, , snmp, squid?
All those services are part of the Application level of the TCP/IP protocol.
http => 80
telnet => 23
ftp => 20 (data transfer), 21 (Connection established)
smtp => 25
dns => 53
snmp => 161
dhcp => 67 (server), 68 (Client)
ssh => 22
squid => 3128 - How many host available in a subnet (Class B and C Networks)
- How DNS works?
When you enter a URL into your Web browser, your DNS server uses its resources to resolve the name into the IP address for the appropriate Web server. - What is the difference between class A, class B and class C IP addresses?
Class A Network (/ 8 Prefixes)
This network is 8-bit network prefix. IP address range from 0.0.0.0 to 127.255.255.255
Class B Networks (/16 Prefixes)
This network is 16-bit network prefix. IP address range from 128.0.0.0 to 191.255.255.255Class C Networks (/24 Prefixes)
This network is 24-bit network prefix.IP address range from 192.0.0.0 to 223.255.255.255 - Difference between ospf and bgp?
The first reason is that BGP is more scalable than OSPF. , and this, normal igp like ospf cannot perform. Generally speaking OSPF and BGP are routing protocols for two different things. OSPF is an IGP (Interior Gateway Protocol) and is used internally within a companies network to provide routing.
II- Operating System
1&1 Web Hosting
- How to find the Operating System version?
$uname -a
To check the distribution for redhat for example: $cat /etc/redhat –release - How to list all the process running?
top
To list java processes, ps -ef | grep java
To list processes on a specific port:
netstat -aon | findstr :port_number
lsof -i:80 - How to check disk space?
df shows the amount of disk space used and available.
du displays the amount of disk used by the specified files and for each subdirectories.
To drill down and find out which file is filling up a drive: du -ks /drive_name/* | sort -nr | head - How to check memory usage?
free or cat /proc/meminfo - What is the load average?
It is the average sum of the number of process waiting in the queue and the number of process currently executing over the period of 1, 5 and 15 minutes. Use top to find the load average. - What is a load balancer?
A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications. - What is the Linux Kernel?
The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction. - What is the default kill signal?
There are many different signals that can be sent (see signal for a full list), although the signals in which users are generally most interested are SIGTERM (“terminate”) and SIGKILL (“kill”). The default signal sent is SIGTERM.
kill 1234
kill -s TERM 1234
kill -TERM 1234
kill -15 1234 - Describe Linux boot process
BIOS => MBR => GRUB => KERNEL => INIT => RUN LEVEL
As power comes up, the BIOS (Basic Input/Output System) is given control and executes MBR (Master Boot Record). The MBR executes GRUB (Grand Unified Boot Loader). GRUB executes Kernel. Kernel executes /sbin/init. Init executes run level programs. Run level programs are executed from /etc/rc.d/rc*.d
Mac OS X Boot Process:Boot ROM Firmware. Part of Hardware system
BootROM firmware is activatedPOST Power-On Self Test
initializes some hardware interfaces and verifies that sufficient memory is available and in a good state.EFI Extensible Firmware Interface
EFI does basic hardware initialization and selects which operating system to use.BOOTX boot.efi boot loader
load the kernel environmentRooting/Kernel The init routine of the kernel is executed
boot loader starts the kernel’s initialization procedure
Various Mach/BSD data structures are initialized by the kernel.
The I/O Kit is initialized.
The kernel starts /sbin/mach_initRun Level mach_init starts /sbin/init
init determines the runlevel, and runs /etc/rc.boot, which sets up the machine enough to run single-user.
rc.boot figures out the type of boot (Multi-User, Safe, CD-ROM, Network etc.) - List services enabled at a particular run level
chkconfig –list | grep 5:0n
Enable|Disable a service at a specific run level: chkconfig on|off –level 5 - How do you stop a bash fork bomb?
Create a fork bomb by editing limits.conf:
root hard nproc 512
Drop a fork bomb as below:
:(){ :|:& };:
Assuming you have access to shell:
kill -STOP
killall -STOP -u user1
killall -KILL -u user1 - What is a fork?
fork is an operation whereby a process creates a copy of itself. It is usually a system call, implemented in the kernel. Fork is the primary (and historically, only) method of process creation on Unix-like operating systems. - What is the D state?
D state code means that process is in uninterruptible sleep, and that may mean different things but it is usually I/O.
III- File System
- What is umask?
umask is “User File Creation Mask”, which determines the settings of a mask that controls which file permissions are set for files and directories when they are created. - What is the role of the swap space?
A swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
- What is the role of the swap space?
A swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing. - What is the null device in Linux?
The null device is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams. This is usually done by redirection. The /dev/null device is a special file, not a directory, so one cannot move a whole file or directory into it with the Unix mv command.You might receive the “Bad file descriptor” error message if /dev/null has been deleted or overwritten. You can infer this cause when file system is reported as read-only at the time of booting through error messages, such as“/dev/null: Read-only filesystem” and “dup2: bad file descriptor”.
In Unix and related computer operating systems, a file descriptor (FD, less frequently fildes) is an abstract indicator (handle) used to access a file or other input/output resource, such as a pipe or network socket. - What is a inode?
The inode is a data structure in a Unix-style file system that describes a filesystem object such as a file or a directory. Each inode stores the attributes and disk block location(s) of the object’s data.
IV- Databases
- What is the difference between a document store and a relational database?
In a relational database system you must define a schema before adding records to a database. The schema is the structure described in a formal language supported by the database and provides a blueprint for the tables in a database and the relationships between tables of data. Within a table, you need to define constraints in terms of rows and named columns as well as the type of data that can be stored in each column.In contrast, a document-oriented database contains documents, which are records that describe the data in the document, as well as the actual data. Documents can be as complex as you choose; you can use nested data to provide additional sub-categories of information about your object. You can also use one or more document to represent a real-world object. - How to optimise a slow DB?
- Rewrite the queries
- Change indexing strategy
- Change schema
- Use an external cache
- Server tuning and beyond
- How would you build a 1 Petabyte storage with commodity hardware?
Using JBODs with large capacity disks with Linux in a distributed storage system stacking nodes until 1PB is reached.
JBOD (which stands for “just a bunch of disks”) generally refers to a collection of hard disks that have not been configured to act as a redundant array of independent disks (RAID) array.
V- Scripting
- What is @INC in Perl?
The @INC Array. @INC is a special Perl variable that is the equivalent to the shell’s PATH variable. Whereas PATH contains a list of directories to search for executables, @INC contains a list of directories from which Perl modules and libraries can be loaded. - Strings comparison – operator – for loop – if statement
- Sort access log file by http Response Codes
Via Shell using linux commands
cat sample_log.log | cut -d ‘”‘ -f3 | cut -d ‘ ‘ -f2 | sort | uniq -c | sort -rn - Sort access log file by http Response Codes Using awk
awk ‘{print $9}’ sample_log.log | sort | uniq -c | sort -rn - Find broken links from access log file
awk ‘($9 ~ /404/)’ sample_log.log | awk ‘{print $7}’ sample_log.log | sort | uniq -c | sort -rn - Most requested page:
awk -F\” ‘{print $2}’ sample_log.log | awk ‘{print $2}’ | sort | uniq -c | sort -r - Count all occurrences of a word in a file
grep -o “user” sample_log.log | wc -w
Learn more at http://career.guru99.com/top-50-linux-interview-questions/
Real Time Linux Jobs
Script with hash tables on windows and Linux
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
How to declare and write a script with hash tables on windows and linux
A hash table, also known as a hash map, is a data structure that is used to store key-value pairs. It is an efficient way to store data that can be quickly retrieved using a unique key.
Here is an example of how to declare and write a script with a hash table in Python:
# Declare an empty hash tablehash_table = {}
# Add some key-value pairs to the hash table
hash_table[‘key1’] = ‘value1’
hash_table[‘key2’] = ‘value2’
hash_table[‘key3’] = ‘value3’
# Access a value using its key
print(hash_table[‘key2’]) # Output: “value2”
# Modify a value using its key
hash_table[‘key2’] = ‘new value’
print(hash_table[‘key2’]) # Output: “new value”
# Delete a key-value pair using the `del` statement
del hash_table[‘key1’]
# Check if a key is in the hash table using the `in` operator
print(‘key1’ in hash_table) # Output: False
# Output: False
In this example, we declare an empty hash table using the {}
syntax. We then add some key-value pairs to the hash table using the []
syntax. We access a value using its key, modify a value using its key, delete a key-value pair using the del
statement, and check if a key is in the hash table using the in
operator.
I hope this helps! Let me know if you have any questions.
Hash tables with powershell on windows
Declaration:
$states=@{“Alberta” = “Calgary”; “British Columbia” = “Vancouver”; “Ontario” = “Toronto” ; “Quebec” = “Montreal”}Name
_____Value
_______Alberta Calgary British Columbia Vancouver Ontario Toronto Quebec Montreal Add new key-value in hashtable:
$states.Add(“Manitoba”,”Winnipeg”)Remove key-value in hashtable:
$states.Remove(“Manitoba”,”Winnipeg”)
Change value in hashtable:
$states.Set_Item(“Ontario”,”Ottawa”)
Retrieve value in hashtable:
$states.Get_Item(“Alberta”)
Find key in hashtable:
$states.ContainsKey(“Alberta”)
Find Value in hashtable:
$states.ContainsValue(“Calgary”)
Count items in hashtable:
$states.Count
Sort items by Name in hashtable:
$states.GetEnumerator() | Sort-Object Name -descending
Sort items by Value in hashtable:
$states.GetEnumerator() | Sort-Object Value -descendingHash tables with perl on linux or windows
Declaration:
my %hash = (); #Initialize a hash
my $hash_ref = {}; # Initialize a hash reference. ref will return HASH
Clear (or empty) a hash
for (keys %hash)
{
delete $hash{$_};
}
Clear (or empty) a hash reference
for (keys %$href)
{
delete $href->{$_};
}
Add a key/value pair to a hash
$hash{ ‘key’ } = ‘value’; # hash
$hash{ $key } = $value; # hash, using variables
Using Hash Reference
$href->{ ‘key’ } = ‘value’; # hash ref
$href->{ $key } = $value; # hash ref, using variables
Add several key/value pairs to a hash
%hash = ( ‘key1’, ‘value1’, ‘key2’, ‘value2’, ‘key3’, ‘value3’ );
%hash = (
key1 => ‘value1’,
key2 => ‘value2’,
key3 => ‘value3’,
);Copy a hash
my %hash_copy = %hash; # copy a hash
my $href_copy = $href; # copy a hash ref
Delete a single key/value pair
delete $hash{$key};
delete $hash_ref->{$key};
Hash tables with python on linux or windows
Hash tables are called dictionary in python.
Declaration:
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
Accessing Values
print “dict[‘Name’]: “, dict[‘Name’]
print “dict[‘Age’]: “, dict[‘Age’]
Output:
dict[‘Name’]: Zara
dict[‘Age’]: 7
Updating Dictionary
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
dict[‘Age’] = 8; # update existing entry
dict[‘School’] = “DPS School”; # Add new entry
Delete Dictionary Elements
#!/usr/bin/python
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
del dict[‘Name’]; # remove entry with key ‘Name’
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary
Source:
reverse a string on Linux and Windows
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
How to reverse a string on Linux and Windows
On Linux:
- Using the
rev
command: Therev
command is a utility that reverses the lines of a file or the characters in a string. To reverse a string, you can use theecho
command to pass the string torev
:
echo "string" | rev
- Using the
sed
command: Thesed
command is a powerful utility that can perform various text transformations. To reverse a string, you can use thesed
command with the-r
option and the's/.*(.)/\1/g'
expression:
echo "string" | sed -r 's/.*(.)/\1/g'
- Using the
awk
command: Theawk
command is a programming language that is used for text processing. To reverse a string, you can use theawk
command with the{print}
action:
echo "string" | awk '{print $1}'
On Windows:
- Using the
powershell
command: Thepowershell
command is a shell that provides a command-line interface for Windows. To reverse a string, you can use thepowershell
command with the-C
option and the'[System.Text.Encoding]::Unicode.GetString([System.Text.Encoding]::Unicode.GetBytes("string"))'
expression:
powershell -C "[System.Text.Encoding]::Unicode.GetString([System.Text.Encoding]::Unicode.GetBytes("string"))"
- Using the
cmd
command: Thecmd
command is the command-line interpreter for Windows. To reverse a string, you can use thecmd
command with thefor
loop:
cmd /c "for /L %i in (1,1,%len%) do @echo !string:~%len%-%i,1!"
These are some ways to reverse a string on Linux and Windows. There are other ways to achieve this, using different utilities or programming languages.
Via shell script on Linux
sh-3.2# vi reverse.sh
#### Start Script #####
#!/bin/bash
input_string=”$1″
reverse_string=””
input_string_length=${#input_string}
for (( i=$input_string_length-1; i>=0; i– ))
do
reverse_string=”$reverse_string${input_string:$i:1}”
done
echo “$reverse_string”
##### End Script #####
Let’s run it:
sh-3.2# chmod 775 reverse.sh
sh-3.2# ./reverse.sh Etienne
enneitE
Via powershell script on Windows
#Let’s use the script reverse.ps1 below.
######
$string=”Etienne”
$string_array=$string -split “”
[array]::Reverse($string_array)
$string_array -join ”
#####Output#####
PS C:\Users\etienne_noumen\Documents\Etienne\Scripting> .\reverse.ps1
E t i e n n e
enneitE
Via powershell script on Windows in one line
([regex]::Matches($String,’.’,’RightToLeft’) | ForEach {$_.value}) -join ”
Via batch script on Windows
::Note: ReverseStr also calls StrLen
::and string length is not greater than 80 chars
:: but can be changed.
@echo off
SetLocal EnableDelayedExpansion
cls
set Str=Etienne
call :StrLen %Str%
echo Length=%Len%
call :ReverseStr %Str%
echo String=%Str%
echo Reverse Str=%Reverse%
exit /b
Set yourself up for promotion or get a better job by Acing the AWS Certified Data Engineer Associate Exam (DEA-C01) with the eBook or App below (Data and AI)
![](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20210%20140%22%3E%3C/svg%3E)
Download the Ace AWS DEA-C01 Exam App:
iOS - Android
AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version
::—————-
:: Calc Var Length
::—————-
:: %*=Str to Check
:: Returns %Len%
:: —————
:StrLen %*
set Data=%*
for /L %%a in (0,1,80) do (
set Char=!Data:~%%a,1!
if not “!Char!”==”” (
set /a Len=%%a+1
) else (exit /b)
)
exit /b
::—————
:: Reverse String
::—————
:: %* Str to Reverse
:: Returns %Reverse%
::——————
:ReverseStr %*
set Data=%*
call :StrLen %Data%
for /L %%a in (!Len!,-1,0) do (
set Char=!Data:~%%a,1!
set Reverse=!Reverse!!Char!
)
exit /b
Invest in your future today by enrolling in this Azure Fundamentals - Pass the Azure Fundamentals Exam with Ease: Master the AZ-900 Certification with the Comprehensive Exam Preparation Guide!
- AWS Certified AI Practitioner (AIF-C01): Conquer the AWS Certified AI Practitioner exam with our AI and Machine Learning For Dummies test prep. Master fundamental AI concepts, AWS AI services, and ethical considerations.
- Azure AI Fundamentals: Ace the Azure AI Fundamentals exam with our comprehensive test prep. Learn the basics of AI, Azure AI services, and their applications.
- Google Cloud Professional Machine Learning Engineer: Nail the Google Professional Machine Learning Engineer exam with our expert-designed test prep. Deepen your understanding of ML algorithms, models, and deployment strategies.
- AWS Certified Machine Learning Specialty: Dominate the AWS Certified Machine Learning Specialty exam with our targeted test prep. Master advanced ML techniques, AWS ML services, and practical applications.
- AWS Certified Data Engineer Associate (DEA-C01): Set yourself up for promotion, get a better job or Increase your salary by Acing the AWS DEA-C01 Certification.
Via perl script on Windows or Linux
Via python script on Windows or Linux
def reverse_string(a_string)
return a_string[::-1]
reverse_string(“etienne”) returns “enneite”
Source:
Linux Boot process
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
Let’s describe Linux Boot Process:
The Linux boot process involves several stages, in which the operating system performs various tasks to prepare the system for use.
- When the system is powered on, the BIOS (Basic Input/Output System) or the UEFI (Unified Extensible Firmware Interface) performs a power-on self-test (POST) to check the hardware components and to load the bootloader.
- The bootloader, such as GRUB (GRand Unified Bootloader), is responsible for loading the operating system kernel and transferring control to it.
- The operating system kernel, which is the core of the operating system, initializes the system and starts the system services.
- The system services, such as the device drivers, are loaded and initialized.
- The operating system loads the user profile and starts the user interface, such as the desktop or the login screen.
- The user can log in and start using the system.
This is a general overview of the Linux boot process. The exact sequence of events may vary depending on the specific distribution of Linux and the hardware configuration of the system.
BIOS | Basic INPUT/OUTPUT System. Executes MBR |
MBR | Master Boot Record Executes GRUB |
GRUB | Grand Unified Bootloader Executes kernel |
KERNEL | Kernel Executes /sbin/init |
INIT | Init Executes Run level programs |
Run Level | Run Level Programs are executed from /etc/rc.d/rc*.d/ |
- As power comes up the BIOS is given control
- BIOS runs self tests, usually including cursory memory tests.
- The BIOS then loads the first sector of the disk to be used for booting and transfers control to it.
- The MBR code varies. One version will chain to the code in the first sector of the boot partition (Windows), another will load a bootloader. Windows boot proceeds from code and information in the boot partition.
- The bootloader chooses kernel location and version
- The bootloader prepares kernel and initrd image in memory, transfers control to kernel
- Loading kernel modules
- Discovering hardware and load additional kernel modules to support it
- Looking for disks
- R/O mount of / partition so that it can potentially be checked and repaired
- init process spawn
- /etc/inittab read and executing
- Mounting all FSes from /etc/fstab
- runlevels running (based on default runlevel in /etc/inittab) or another init method such as systemd or upstart
- rc.local
- login prompt
Source:
Monitor Macbook
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
How to Monitor Macbook with one single command?
$sudo sysdiagnose -f ~/Desktop/
The result is a compressed file named sysdiagnose_YYYY.MM.DD_HH-MM-SS-TTTT.tar.gz and it contains the following:
Accessibility
BluetoothTraceFile.pklg
DiagnosticMessages
Etienne’s SystemConfiguration
airport_info.txt
apsd-status.txt
bc_stats.txt
bootstamps.txt
brctl.tar.gz
breadcrumbs.txt
crashes_and_spins
darwinup.txt
dig-results.txt
disks.txt
diskutil.txt
error_log.txt
filecoordination_dump.txt
footprint-all.txt
fs_usage.txt
fsck_hfs_user.log
fsck_hfs_var.log
gpt.txt
ifconfig.txt
ioreg
ipconfig.txt
kextstat.txt
launchctl-list.txt
locale.txt
logs
lsappinfo.txt
lsmp.txt
lsof.txt
lsregister.txt
microstackshots
microstackshots_lastday.txt
microstackshots_lasthour.txt
microstackshots_lastminute.txt
mount.txt
netstat
nfsstat.txt
odutil.txt
pluginkit.txt
pmset_everything.txt
powermetrics.txt
ps.txt
ps_thread.txt
reachability-info.txt
resolv.conf
scutil.txt
smcDiagnose.txt
spindump.txt
stackshot-last-sym.log
sysctl.txt
sysdiagnose.log
system_profiler.spx
talagent.txt
taskinfo.txt
thermal.txt
top.txt
var_run_resolv.conf
vm_stat.txt
zprint.txt
You can use the top
command to monitor the resources of your Macbook in real-time. The top
command is a built-in utility that shows the processes that are currently running on the system, along with information about their CPU and memory usage.
To use the top
command, open a terminal window and type top
. The output will show the list of processes, sorted by their CPU usage, with the most CPU-intensive processes at the top. You can use the q
key to exit the top
command.
Here are some of the key options you can use with the top
command:
-o
: sort the processes by a particular resource, such as CPU usage or memory usage. For example,top -o cpu
will sort the processes by CPU usage.-s
: specify the delay between updates. For example,top -s 2
will update the display every 2 seconds.-u
: show the process for a particular user. For example,top -u username
will show the processes for the user with the specified username.
You can use these options in combination to customize the output of the top
command. For example, to monitor the CPU usage of the processes owned by a particular user, you can use the following command:
top -o cpu -s 2 -u username
List only regular file names in a directory
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
How to List only regular file names in a directory on Linux and Windows
Listing regular files in a directory without including . and .. files.
On Linux
Solution 1:$ ls -p | grep -v /
Solution 2: $ ls -F | grep -v ‘[/@=|]’
Solution 3: $for list in `ls` ; do ls -ld $list | grep -v ^d > /dev/null && echo $list ; done ;
Solution4:$ for list in `ls` ; do ls -ld $list | grep ^d > /dev/null || echo $list ; done ;
Solution5 (exclude sym links):$ for list in `ls` ; do ls -ld $list | grep -v ^l > /dev/null && echo $list ; done ;On Windows
Solution 1: dir /a-d /b >..\File_List.txt
Set Date and time via command line
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
Let’s find out how to set Date and time via command line on linux and windows:
On Linux via terminal
System time (Must have sudo privilege)
date -s ‘2015-07-28 15:27:30’
Hardware time
Let’s set the hardware clock to the current system time:
hwclock –systohc
On Windows via command prompt terminal
System time (Must have Administrator privilege)
date
The current date is: 07/28/2015
Enter the new date: (mm-dd-yy)_
time
The current time is: 15:34:03.44
Enter the new time: _
prompt and read input variables from keyboard
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
Let’s find how to prompt and read input variables from keyboard while executing a script using shell, perl, python, batch and powershell (windows and Linux)
On Linux via shell
read -p “Enter your name: ” name
echo “Hi, $name. Let’s be friend!”
On Windows via powershell
$name=read-host “Enter your name:”
write-host “Hi $name, Let’s be friend!”On Windows via batch
Set /p Name=”Enter your name:”
echo “Hi %name%, Let’s be friend!”On Windows or Linux via perl
print “Enter your name “;
my $name =;
chomp $name; # Get rid of newline character at the end
print “Hello $name, let’s be friend”;On Windows or Linux via python
name=input(“Enter your name: “)
print (“Hello ” + name + ” let’s be friend”)
List all processes holding a specific port
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_gmail_en.png)
![](https://storage.googleapis.com/referworkspace-asset/img/digitalbuttons/digital_button_en.png)
Elevate Your Career with AI & Machine Learning For Dummies PRO and Start mastering the technologies shaping the future—download now and take the next step in your professional journey!
How to list all processes holding a specific port on Linux and windows via command line
Let’s find all processes pid using port 80 on linux and windows:
On Linux
lsof -i:80
On Windows
netstat -aon | findstr :80
What is Google Workspace?
Google Workspace is a cloud-based productivity suite that helps teams communicate, collaborate and get things done from anywhere and on any device. It's simple to set up, use and manage, so your business can focus on what really matters.
Watch a video or find out more here.
Here are some highlights:
Business email for your domain
Look professional and communicate as you@yourcompany.com. Gmail's simple features help you build your brand while getting more done.
Access from any location or device
Check emails, share files, edit documents, hold video meetings and more, whether you're at work, at home or on the move. You can pick up where you left off from a computer, tablet or phone.
Enterprise-level management tools
Robust admin settings give you total command over users, devices, security and more.
Sign up using my link https://referworkspace.app.goo.gl/Q371 and get a 14-day trial, and message me to get an exclusive discount when you try Google Workspace for your business.
Google Workspace Business Standard Promotion code for the Americas
63F733CLLY7R7MM
63F7D7CPD9XXUVT
63FLKQHWV3AEEE6
63JGLWWK36CP7WM
Email me for more promo codes
Active Hydrating Toner, Anti-Aging Replenishing Advanced Face Moisturizer, with Vitamins A, C, E & Natural Botanicals to Promote Skin Balance & Collagen Production, 6.7 Fl Oz
Age Defying 0.3% Retinol Serum, Anti-Aging Dark Spot Remover for Face, Fine Lines & Wrinkle Pore Minimizer, with Vitamin E & Natural Botanicals
Firming Moisturizer, Advanced Hydrating Facial Replenishing Cream, with Hyaluronic Acid, Resveratrol & Natural Botanicals to Restore Skin's Strength, Radiance, and Resilience, 1.75 Oz
Skin Stem Cell Serum
Smartphone 101 - Pick a smartphone for me - android or iOS - Apple iPhone or Samsung Galaxy or Huawei or Xaomi or Google Pixel
Can AI Really Predict Lottery Results? We Asked an Expert.
![](https://djamgatech.com/wp-content/uploads/2022/05/azure_fundamentals_book_cover1.jpeg)
![Football/Soccer World Cup 2022 Guide and Past World Cups History and Quiz illustrated](https://sp-ao.shortpixel.ai/client/to_auto,q_glossy,ret_img,w_300/http://enoumen.com/wp-content/uploads/2022/10/world_cup_guide_quiz_trivia3.png)
Djamgatech
![](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20400%20266.66666666667%22%3E%3C/svg%3E)
Read Photos and PDFs Aloud for me iOS
Read Photos and PDFs Aloud for me android
Read Photos and PDFs Aloud For me Windows 10/11
Read Photos and PDFs Aloud For Amazon
Get 20% off Google Workspace (Google Meet) Business Plan (AMERICAS): M9HNXHX3WC9H7YE (Email us for more)
Get 20% off Google Google Workspace (Google Meet) Standard Plan with the following codes: 96DRHDRA9J7GTN6(Email us for more)
FREE 10000+ Quiz Trivia and and Brain Teasers for All Topics including Cloud Computing, General Knowledge, History, Television, Music, Art, Science, Movies, Films, US History, Soccer Football, World Cup, Data Science, Machine Learning, Geography, etc....
![](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20210%20140%22%3E%3C/svg%3E)
List of Freely available programming books - What is the single most influential book every Programmers should read
- Bjarne Stroustrup - The C++ Programming Language
- Brian W. Kernighan, Rob Pike - The Practice of Programming
- Donald Knuth - The Art of Computer Programming
- Ellen Ullman - Close to the Machine
- Ellis Horowitz - Fundamentals of Computer Algorithms
- Eric Raymond - The Art of Unix Programming
- Gerald M. Weinberg - The Psychology of Computer Programming
- James Gosling - The Java Programming Language
- Joel Spolsky - The Best Software Writing I
- Keith Curtis - After the Software Wars
- Richard M. Stallman - Free Software, Free Society
- Richard P. Gabriel - Patterns of Software
- Richard P. Gabriel - Innovation Happens Elsewhere
- Code Complete (2nd edition) by Steve McConnell
- The Pragmatic Programmer
- Structure and Interpretation of Computer Programs
- The C Programming Language by Kernighan and Ritchie
- Introduction to Algorithms by Cormen, Leiserson, Rivest & Stein
- Design Patterns by the Gang of Four
- Refactoring: Improving the Design of Existing Code
- The Mythical Man Month
- The Art of Computer Programming by Donald Knuth
- Compilers: Principles, Techniques and Tools by Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman
- Gödel, Escher, Bach by Douglas Hofstadter
- Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
- Effective C++
- More Effective C++
- CODE by Charles Petzold
- Programming Pearls by Jon Bentley
- Working Effectively with Legacy Code by Michael C. Feathers
- Peopleware by Demarco and Lister
- Coders at Work by Peter Seibel
- Surely You're Joking, Mr. Feynman!
- Effective Java 2nd edition
- Patterns of Enterprise Application Architecture by Martin Fowler
- The Little Schemer
- The Seasoned Schemer
- Why's (Poignant) Guide to Ruby
- The Inmates Are Running The Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity
- The Art of Unix Programming
- Test-Driven Development: By Example by Kent Beck
- Practices of an Agile Developer
- Don't Make Me Think
- Agile Software Development, Principles, Patterns, and Practices by Robert C. Martin
- Domain Driven Designs by Eric Evans
- The Design of Everyday Things by Donald Norman
- Modern C++ Design by Andrei Alexandrescu
- Best Software Writing I by Joel Spolsky
- The Practice of Programming by Kernighan and Pike
- Pragmatic Thinking and Learning: Refactor Your Wetware by Andy Hunt
- Software Estimation: Demystifying the Black Art by Steve McConnel
- The Passionate Programmer (My Job Went To India) by Chad Fowler
- Hackers: Heroes of the Computer Revolution
- Algorithms + Data Structures = Programs
- Writing Solid Code
- JavaScript - The Good Parts
- Getting Real by 37 Signals
- Foundations of Programming by Karl Seguin
- Computer Graphics: Principles and Practice in C (2nd Edition)
- Thinking in Java by Bruce Eckel
- The Elements of Computing Systems
- Refactoring to Patterns by Joshua Kerievsky
- Modern Operating Systems by Andrew S. Tanenbaum
- The Annotated Turing
- Things That Make Us Smart by Donald Norman
- The Timeless Way of Building by Christopher Alexander
- The Deadline: A Novel About Project Management by Tom DeMarco
- The C++ Programming Language (3rd edition) by Stroustrup
- Patterns of Enterprise Application Architecture
- Computer Systems - A Programmer's Perspective
- Agile Principles, Patterns, and Practices in C# by Robert C. Martin
- Growing Object-Oriented Software, Guided by Tests
- Framework Design Guidelines by Brad Abrams
- Object Thinking by Dr. David West
- Advanced Programming in the UNIX Environment by W. Richard Stevens
- Hackers and Painters: Big Ideas from the Computer Age
- The Soul of a New Machine by Tracy Kidder
- CLR via C# by Jeffrey Richter
- The Timeless Way of Building by Christopher Alexander
- Design Patterns in C# by Steve Metsker
- Alice in Wonderland by Lewis Carol
- Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig
- About Face - The Essentials of Interaction Design
- Here Comes Everybody: The Power of Organizing Without Organizations by Clay Shirky
- The Tao of Programming
- Computational Beauty of Nature
- Writing Solid Code by Steve Maguire
- Philip and Alex's Guide to Web Publishing
- Object-Oriented Analysis and Design with Applications by Grady Booch
- Effective Java by Joshua Bloch
- Computability by N. J. Cutland
- Masterminds of Programming
- The Tao Te Ching
- The Productive Programmer
- The Art of Deception by Kevin Mitnick
- The Career Programmer: Guerilla Tactics for an Imperfect World by Christopher Duncan
- Paradigms of Artificial Intelligence Programming: Case studies in Common Lisp
- Masters of Doom
- Pragmatic Unit Testing in C# with NUnit by Andy Hunt and Dave Thomas with Matt Hargett
- How To Solve It by George Polya
- The Alchemist by Paulo Coelho
- Smalltalk-80: The Language and its Implementation
- Writing Secure Code (2nd Edition) by Michael Howard
- Introduction to Functional Programming by Philip Wadler and Richard Bird
- No Bugs! by David Thielen
- Rework by Jason Freid and DHH
- JUnit in Action
#BlackOwned #BlackEntrepreneurs #BlackBuniness #AWSCertified #AWSCloudPractitioner #AWSCertification #AWSCLFC02 #CloudComputing #AWSStudyGuide #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AWSBasics #AWSCertified #AWSMachineLearning #AWSCertification #AWSSpecialty #MachineLearning #AWSStudyGuide #CloudComputing #DataScience #AWSCertified #AWSSolutionsArchitect #AWSArchitectAssociate #AWSCertification #AWSStudyGuide #CloudComputing #AWSArchitecture #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AzureFundamentals #AZ900 #MicrosoftAzure #ITCertification #CertificationPrep #StudyMaterials #TechLearning #MicrosoftCertified #AzureCertification #TechBooks
Top 1000 Canada Quiz and trivia: CANADA CITIZENSHIP TEST- HISTORY - GEOGRAPHY - GOVERNMENT- CULTURE - PEOPLE - LANGUAGES - TRAVEL - WILDLIFE - HOCKEY - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
![zCanadian Quiz and Trivia, Canadian History, Citizenship Test, Geography, Wildlife, Secenries, Banff, Tourism](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20400%20266.66666666667%22%3E%3C/svg%3E)
Top 1000 Africa Quiz and trivia: HISTORY - GEOGRAPHY - WILDLIFE - CULTURE - PEOPLE - LANGUAGES - TRAVEL - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
![Africa Quiz, Africa Trivia, Quiz, African History, Geography, Wildlife, Culture](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20400%20266.66666666667%22%3E%3C/svg%3E)
Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada.
![Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20300%20200%22%3E%3C/svg%3E)
Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA
![Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA](data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20300%20200%22%3E%3C/svg%3E)
Health Health, a science-based community to discuss human health
- Scientists in Italy discover rare gene that could cause Alzheimer’sby /u/euronews-english on January 22, 2025 at 1:49 pm
submitted by /u/euronews-english [link] [comments]
- Childhood Vaccination Rates Continue to Slipby /u/Generalaverage89 on January 22, 2025 at 1:20 pm
submitted by /u/Generalaverage89 [link] [comments]
- Trump’s Plan to Leave the WHO Is a Health Disasterby /u/wiredmagazine on January 22, 2025 at 11:17 am
submitted by /u/wiredmagazine [link] [comments]
- FDA allows standalone use of nasal spray antidepressant Spravato (esketamine)by /u/Maxcactus on January 22, 2025 at 10:35 am
submitted by /u/Maxcactus [link] [comments]
- Eating too much red meat linked to an increased risk of dementia and cognitive declineby /u/euronews-english on January 22, 2025 at 9:49 am
submitted by /u/euronews-english [link] [comments]
Today I Learned (TIL) You learn something new every day; what did you learn today? Submit interesting and specific facts about something that you just found out here.
- TIL the T4 Program was a Nazi German euthanasia program that forcibly killed the physically or mentally disabled, the emotionally distraught, elderly people and the incurably ill. The death toll may have reached 200,000 or moreby /u/wilsonofoz on January 22, 2025 at 2:19 pm
submitted by /u/wilsonofoz [link] [comments]
- TIL that inventors of the two most impactful weapon technologies of WWII, Merle Tuve (proximity fuse) and Ernest Lawrence (uranium enrichment for the atomic bomb) were childhood friends and neighbors from the same small town in South Dakotaby /u/JiveChicken00 on January 22, 2025 at 1:38 pm
submitted by /u/JiveChicken00 [link] [comments]
- TIL that there is a species of whale that has been living in the oceans for millions of years, but it was only recently discovered due to its isolation in the deep depths.by /u/QuietKnightX on January 22, 2025 at 10:13 am
submitted by /u/QuietKnightX [link] [comments]
- TIL In the Netherland a town exists that fully encloses 22 small exclaves of a Belgian town.by /u/Bangfis on January 22, 2025 at 10:08 am
submitted by /u/Bangfis [link] [comments]
- TIL that a huge 20m (66ft) rogue wave hit the bulk carrier, MV Derbyshire with such force that it sent the ship underwater almost instantly, not even giving its crew enough time to save themselves, let alone send a distress signal.by /u/zahrul3 on January 22, 2025 at 9:10 am
submitted by /u/zahrul3 [link] [comments]
Reddit Science This community is a place to share and discuss new scientific research. Read about the latest advances in astronomy, biology, medicine, physics, social science, and more. Find and submit new publications and popular science coverage of current research.
- Black immigrants attract white residents to neighborhoods, while native Black residents move out, study finds.by /u/geoff199 on January 22, 2025 at 1:24 pm
submitted by /u/geoff199 [link] [comments]
- Antibiotics, antivirals and vaccines could help tackle dementia, study suggests. Using drugs approved for other conditions could dramatically speed up hunt for cure, experts say.by /u/mvea on January 22, 2025 at 12:10 pm
submitted by /u/mvea [link] [comments]
- Study links early emotional regulation difficulties to ADHD and conduct problems | The findings highlight the importance of early emotional development and could guide targeted support for children at risk.by /u/chrisdh79 on January 22, 2025 at 11:02 am
submitted by /u/chrisdh79 [link] [comments]
- Researchers have discovered that proteins in the mollusk’s blood not only have bacteria-killing properties, raising the possibility of a new antibiotic, but also increase the effectiveness of some existing antibiotics.by /u/chrisdh79 on January 22, 2025 at 10:59 am
submitted by /u/chrisdh79 [link] [comments]
- A new study highlights how scaling up COVID-19 testing in the USA saved an estimated 1.4 million lives and averted 7 million hospitalisations. It emphasises the vital role of rapid testing in reducing severe outcomes and preparing for future pandemics.by /u/calliope_kekule on January 22, 2025 at 10:22 am
submitted by /u/calliope_kekule [link] [comments]
Reddit Sports Sports News and Highlights from the NFL, NBA, NHL, MLB, MLS, and leagues around the world.
- NFL news roundup: Saints rescheduling HC interviews due to severe weatherby /u/EvelynClede on January 22, 2025 at 7:33 am
submitted by /u/EvelynClede [link] [comments]
- 4 arrested in connection with burglary at Joe Burrow's houseby /u/Oldtimer_2 on January 22, 2025 at 4:01 am
submitted by /u/Oldtimer_2 [link] [comments]
- Madison Keys reaches the Australian Open semifinals with a win over Elina Svitolinaby /u/Oldtimer_2 on January 22, 2025 at 3:52 am
submitted by /u/Oldtimer_2 [link] [comments]
- Ichiro Suzuki, CC Sabathia and Billy Wagner elected to Baseball Hall of Fameby /u/Oldtimer_2 on January 22, 2025 at 12:27 am
submitted by /u/Oldtimer_2 [link] [comments]
- Young collector nabs rare Paul Skenes card that could offer him a hefty haul in trade with Piratesby /u/Oldtimer_2 on January 22, 2025 at 12:16 am
submitted by /u/Oldtimer_2 [link] [comments]