Categories
Linux Technology

apt update vs apt upgrade: What’s the difference?

https://dev.to/kcdchennai/apt-update-vs-apt-upgrade-whats-the-difference-2ff8

Categories
Linux Technology

Install def file in ubuntu

Use command below :
sudo dpkg -i PACKAGEFILE

reference :
https://askubuntu.com/questions/1407494/screen-share-not-working-in-ubuntu-22-04-in-all-platforms-zoom-teams-google-m

Categories
Linux Technology

Find software which is using a port on linux

lsof -i :8000

Categories
Linux Shell Technology

Watch all tpc port that are listening :

ss -apt
Categories
Linux Technology

Remove A app from linux completely

first , purge main package name :

sudo apt-get purge mariadb-server 

then

sudo apt autoremove

then run this command to find all packages that may are related to the package which you want to purge :

sudo dpkg -l | grep mariadb 

after that purg services that are returned one by one

Categories
devops Technology

DockerFile properties

ARG

On building a docker image you may want to have some variables (you can also have them in docker-compose)

you can define ARG in docker file (you can also set default value for them in docker file)

for example :

# in docker file
ARG some_variable_name = xxxx
ARG uid

#on building image : 
$ docker build --build-arg some_variable_name=a_value

ENV

ENV variables are also available during the build, as soon as you introduce them with an ENV instruction. However, unlike ARG, they are also accessible by containers started from the final image. ENV values can be overridden when starting a container, more on that below.

# no default value
ENV hey
# a default value
ENV foo /bar
# or ENV foo=/bar

# ENV values can be used during the build
ADD . $foo
# or ADD . ${foo}
# translates to: ADD . /bar


on running docker : 
$ docker run -e "env_var_name=another_value" alpine env

RUN

for example :

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd

ADD , COPY

COPY and ADD are both Dockerfile instructions that serve a similar purpose. They let you copy files from a specific location into a Docker image.

ADD

ADD  does that same but in addition, it also supports 2 other sources. 

  1. A URL instead of a local file/directory.
  2. Extract tar from the source directory into the destination.

COPY

COPY takes in a source and destination. It only lets you copy in a local or directory from your host (the machine-building the Docker image) into the Docker image itself.

for example :

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR

for example:

# Set working directory
WORKDIR /var/www

USER

for example:

USER $user
Categories
Programming Technology Web Development

Pagination in laravel relation

public function get_shop_products($shop_id)
    {
        $shop = Shop::query()
            ->where('id' , $shop_id)
            ->first();
        $shop->setRelation('products' , $shop->products()->paginate(10));
        return new ShopProductsResource($shop);
    }

Masoud Hosseini

Categories
Linux Technology

Why my web server doesnt work ? (ubuntu)

Check 80 port on your server :

sudo netstat -tulpn | grep :80

In my case I saw my 80 port have gotten by Nginx but I want to give it to Apache so I used this command :

sudo systemctl stop nginx
sudo systemctl start apache2.service

and it worked perfectly

Categories
Programming Technology Useful Addresses Web Development

I love Frappe Framework

In this post, I want to write about a miracle in the software development world.

Imagine you can create your database entities with some clicks; you have many types of fields that are built in that software.

For a programmer who codes in pure PHP or python with a front-end framework, it takes more than 1 month to create a blog and shop website, but you can have all of that in one or two days with Frappe; Wow 🙂 What amazing!

You can read more about it on its official website: frappeframework.com

I also created a GitHub repository to keep some sample script codes that during working with frappe you probably need to use.

You can have it here (don’t forget to give it a start and communicate):

https://github.com/masoud-me/frappe-sample-scripts

Categories
devops Linux Technology

How to run our own Smart DNS to bypass geo restrictions – let’s run something like shecan.ir

The article in the link below helps in this way.

Check it out.

https://maj0rmil4d.medium.com/how-to-run-our-own-smart-dns-to-bypass-geo-restrictions-beeeab4f82d7