Information lookup services and authentication protocols rely on secure passwords to remain credible—the Network Information Service is no exception. You can set up these passwords during configuration or when adding users. However, you can still change the user passwords from time to time.

Interestingly, users can effectively change their NIS passwords using the various methods. But irrespective of your chosen method, you must use the NIS yppasswd command.

This article will take you through the various ways to change your NIS passwords. Notably, it will focus on how you can do this using the yppasswd daemon.

Let’s go!

How to Use the yppasswd Command to Change the NIS Passwords

The standard model of installing or changing the NIS passwords is through the yppasswd daemon. The command is an seudónimo for the passwd command. The yppasswd command modifies the /etc/passwd file merienda the user logs into the master server. Of course, you will need to rebuild the passwd map manually.

To change an NIS password, you must be the owner of that password. However, the root users on NIS servers have the privilege to change another user’s password even without knowing the respective user’s flamante password.

This action is possible by entering the root user’s password instead of the user’s flamante password. Notably, this privilege is not available for the root users who are accessing the system from an NIS client machine.

The syntax for this utility is as follows:

The two sobresaliente flags in the above synopsis are as follows:

  • -f [ Name ] – This flag helps to change the gecos information (information in the /etc/passwd file) in the NIS maps for every User Name.
  • -s [ Name [ ShellProg ]] – This flag changes the login shell in the maps for any User Name.

How the yppasswd Works

Merienda the yppasswd command is already running on your master server, you can proceed to change the passwords from any host within the domain by typing the following command:

Merienda you enter the given utility in the command line, the system will prompt you to enter the old password. Mostly, the NIS passwords should have a minimum of six characters.

If you enter an incorrect old password, you will not get an error message until you key in your new password. This happens because the system needs both passwords simultaneously to activate the update protocol. So, the system will only inform you if the old password is wrong after you click the update button.

The following are the three ways on how you can use the yppasswd command to change NIS passwords:

a. Change the NIS Password of a User

Notably, the previous command is handy when changing a user’s credentials. The user can handle this independently. Alternatively, a root user on a server machine can change any user’s password even without knowing the user’s existing password.

Tweak the command as shown in the following illustration. The example demonstrates how you can change the password for a user named Ken in your system. The system will prompt you to enter Ken’s password. If you are a root user on a server machine and do not know Ken’s current password, use your password before entering a new password for Ken.

b. Change the Login Shell of a User

You can also change a user’s login shell using the yppasswd daemon. You will get a prompt for the user’s new shell as the old shell comes as a default. Notably, you should do this if the yppasswd utility does not have a –noshell flag when it is run.

For example, you can change the login shell of the user named Ken to /bin/ksh using the following command:

c. Change the Gecos Information of a User

Finally, you can use the command to change the gecos information of a user, as can be found in the passswd file. Similar with the login shell modifications, this only happens when the yppasswdd utility is not started with the –nogecos flag.

Conclusion

The given examples are some of the common ways through which you can change the NIS passwords. Hopefully, this article is helpful and you can now go through the procedure independently.

Sources:



Source link


What Is File Validation in Laravel?

Laravel validation is a way to perform a validation role. We can check the file type, file size, etc. File validation is typically used to avoid unwanted file uploads in a server or application.

Today, we will learn about file upload and storing in Laravel 9.

Project requirements are provided below:

  • MySQL 8.0+
  • MariaDB 10.2+
  • PHP 8.1

Here is an example of defining the FileUpload:

  1. Process 1. Create a FileUpload Project
  2. Process 2. FileUpload Project Database Connection
  3. Process 3. Create a Model and Controller in the FileUpload Project
  4. Process 4. Run and Test the FileUpload Project

Process 1. Create a FileUpload Project

Step 1 is to run this command line to install Laravel 9 on our server or pc. For that, we need to open the Windows SSH terminal in the folder.

Composer createproject Laravel/Laravel FileUpload

Process 2. FileUpload Project Database Connection

Open the .env file on the FileUpload project and add a new database name, username, and password.

Here is the following code:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= FileUpload Database name
DB_USERNAME= FileUpload Database user name
DB_PASSWORD= FileUpload Database password

Process 3. Create a Model and Controller in the FileUpload Project

Merienda the database is connected, we must create a model and controller for the FileUpload Project.

For that, we need to run the following command:

php artisan make:model FileUpload mc

Now, go to “databasemigrations2022_07_11_074014_create_file_uploads_table.php” file. This name could be different on your side. Now, we need to put these two lines in the file:

$table>string(‘file_name’)>nullable();
$table>string(‘file_path_location’)>nullable();

Its looks like this

return new class extends Migration
{
   
    public function up()
    {
        Schema::create(‘file_uploads’, function (Blueprint $table) {
            $table->id();
            $table->string(‘file_name’)->nullable();
            $table->string(‘file_path_location’)->nullable();
            $table->timestamps();
        });
    }

   
    public function down()
    {
        Schema::dropIfExists(‘file_uploads’);
    }
};

We modify our FileUpload model in “appModelsFileUpload.php”. We add fillable property there. The code is shown below:

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class FileUpload extends Model
{
    use HasFactory;
    protected $fillable = [
        ‘file_name’,
        ‘file_path_location’
    ];
}

Now, we need to migrate the table to the database to run this command:

Merienda migration is completed, we need to create two functions. One function is for going to the upload page, and another is to upload a file in the directory and store it in the database.

Go to the “appHttpControllersFileUploadController.php” file:

Now, add this code to the controller:

 public function fileview(Request $request)
    {
        return view(‘file-upload’);
    }

And another function is shown below:

 public function uploadTheFile(Request $request)
    {

            $rules = array(
                ‘attachment’ => ‘mimes:jpeg,png,jpg,gif,svg,pdf|max:1000’,
            );
            $messages = array(
                ‘attachment’ => ‘ Image need Less then 1Mb.’,
            );

            $validator = Validator::make($request->all(), $rules, $messages);
            if ($validator->fails()) {
                return redirect()->route(‘fileviews’)->with(‘success’, ‘Successfully Added’);
                return redirect()->route(‘fileviews’)->withErrors($validator);
            }else{
                $imageName = time() . ‘.’ . $request->attachment->extension();
                //remove image before upload

               $path = $request->attachment->move(public_path(‘storage/attachment/’), $imageName);
               $departmentname[‘file_name’] = $imageName;
                $departmentname[‘file_path_location’] = $path;
                FileUpload::create($departmentname);
                return redirect()->route(‘fileviews’)->with(‘error’, ‘No file added’);
            }

    }

In the uploadTheFile function, we used the Validator.

We created this function to upload the view. Thus, we need to create the view in the Laravel view located in “resourcesviewsfile-upload.blade.php”.

Let’s build the view for uploading the file.

Copy the code and paste it into the view.

<!DOCTYPE html>
<html lang=«en»>

<head>
    <meta charset=«utf-8» />
    <meta name=«csrf-token» content=«{{ csrf_token() }}»>
    <meta name=«viewport» content=«width=device-width, initial-scale=1.0»>
    <!– CSS only –>
    <link href=«https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css» rel=«stylesheet»
        integrity=«sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBl6DOitfPri4tjfHxaWutUpFmBp4vmVor» crossorigin=«anonymous»>
    <!– JavaScript Bundle with Popper –>
    <script src=«https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js»
        integrity=«sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2» crossorigin=«anonymous»>
    </script>
</head>

<body>
    <div clas=«container»>
        <div class=«col-lg-12»>

            <div class=«card-box»>
                <div>
                    Message
                    @if ($errors->any())
                    @foreach ($errors->all() as $error)
                    <div>{{$error}}</div>
                    @endforeach
                    @endif
                </div>

            </div>
        </div>

        <div class=«col-lg-12»>
            <div class=«card-box»>
                <form action=«{{ route(‘uploadTheFile’) }}» method=«POST» enctype=«multipart/form-data»>
                    @csrf
                    <div class=«form-group»>
                        <label for=«name»>Upload FIle</label>
                        <input type=«file» class=«form-control» name=«attachment» required>
                    </div>

                    <div class=«text-right»>
                        <button type=«submit» class=«btn btn-success waves-effect waves-light»>Save</button>

                    </div>
                </form>
            </div>
        </div>
    </div>

</html>

Now, we need to create two routes for uploading files in our project:

Route::get(‘/file-view’, [FileUploadController::class, ‘fileview’])->name(‘fileviews’);
Route::post(‘/file-upload’, [FileUploadController::class, ‘uploadTheFile’])->name(‘uploadTheFile’);

Merienda the route is created, go to the “/file-view” and it should look like the following image in the browser:

Process 4. Run and Test the FileUpload Project

Now, we need to run the command and check file upload if it is working or not:

We need to check whether the code is working or not through the route for checking.

Select a file and try to upload it. In my case, it worked fine.

Merienda a file is uploaded, it can be found in the following:

Image is here

Also, it is inserted into the Database.

Conclusion

In this article, we created this Laravel FileUpload project with Laravel 9. Creating a data table in Laravel using FileUpload is very useful to call the file again. We hope this FileUpload project example will help you to understand the file Upload in Laravel 9.



Source link


Laravel 9 log is an integral part of the Laravel 9 application. Basically, it is used as an application for monitoring the application activity. Laravel 9 has robust log services for converting log messages into a file. Today, we will demonstrate Laravel 9 logging. This tutorial helps you to understand your application status. What’s going on with your application. If there were an error in your software, you would see the system error message in your log file. Laravel 9 has a default logging that is based on the Laravel channel.

How It Works

Laravel 9 allows developers to log messages about the system behavior of any application to files, such as the system of error logs, and send them to notify the development teams.

It is based on the Laravel 9 channels. Channels are a specific way of writing a system’s log message. Every channel represents a different destination, and we can send messages to different channels simultaneously.

  1. Process One: Install Laravel 9 in the System
  2. Process Two: Configure Log in Project
  3. Process Three: Run and Test the System

Process One: Install Laravel 9 in the System

We have to run the following command to install our log project:

composer createproject laravel/laravellogProject

It should look like the following image:

Then go to the project root directory and open the logging project.

Process Two: Configure Log in Project

All the project configuration options are located in your application config folder. Now, go to the logging.php file located in the config folder. The logging.php file allows developers to configure logging channels by adding, updating, or deleting.

By default, it should look like the following image:

The stack channel is selected by default. The channels look like the following image in the logging file:

    ‘channels’ => [
        ‘stack’ => [
          => ‘stack’,
            ‘channels’ => [‘single’],
            ‘ignore_exceptions’ => false,
        ],

        ‘single’ => [
            ‘driver’ => ‘single’,
            ‘path’ =>storage_path(‘logs/laravel.log’),
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
        ],

        ‘daily’ => [
            ‘driver’ => ‘daily’,
            ‘path’ =>storage_path(‘logs/laravel.log’),
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
            ‘days’ => 14,
        ],

        ‘slack’ => [
            ‘driver’ => ‘slack’,
            ‘url’ => env(‘LOG_SLACK_WEBHOOK_URL’),
            ‘username’ => ‘Laravel Log’,
            ‘emoji’ =>‘:boom:’,
            ‘level’ =>env(‘LOG_LEVEL’, ‘critical’),
        ],

        ‘papertrail’ => [
            ‘driver’ => ‘monolog’,
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
            ‘handler’ =>env(‘LOG_PAPERTRAIL_HANDLER’, SyslogUdpHandler::class),
            ‘handler_with’ => [
                ‘host’ => env(‘PAPERTRAIL_URL’),
                ‘port’ => env(‘PAPERTRAIL_PORT’),
                ‘connectionString’ => ‘tls://’.env(‘PAPERTRAIL_URL’).‘:’.env(‘PAPERTRAIL_PORT’),
            ],
        ],

        ‘stderr’ => [
            ‘driver’ => ‘monolog’,
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
            ‘handler’ =>StreamHandler::class,
            ‘formatter’ => env(‘LOG_STDERR_FORMATTER’),
            ‘with’ => [
                ‘stream’ => ‘php://stderr’,
            ],
        ],

        ‘syslog’ => [
            ‘driver’ => ‘syslog’,
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
        ],

        ‘errorlog’ => [
            ‘driver’ => ‘errorlog’,
            ‘level’ =>env(‘LOG_LEVEL’, ‘debug’),
        ],

        ‘null’ => [
            ‘driver’ => ‘monolog’,
            ‘handler’ =>NullHandler::class,
        ],

        ‘emergency’ => [
            ‘path’ =>storage_path(‘logs/laravel.log’),
        ],
    ],

A driver regulated the channels. The driver will set what log data will be recorded into the system log file. There are lots of drivers built-in Laravel 9. You have to check Laravel 9 driver documentation for the driver list.

Now, write a log message in the Laravel application. We can pass a log message throw log data.

For that, we have to create a controller named “Logmessage”. Now, we need to run this command:

php artisan make:controllerLogmessage

After being created, it should look like this:

Now, we need to create a function in the controller:

class Logmessage extends Controller
{
    public function logtest()
    {

Log::info(» Here is dummy log data»);
        return view(‘welcome’);
    }
}

We use log::info to see the logmessage.

Process Three: Run and Test the System

Now, run and test the logging project.

We need to create a route for checking.

Next, we need to run the project and use the following command:

Then, go to the route and log in to your application.

Before loading the URL, you can check under the storage directory.

There is no log file.

Merienda you load the URL, it will show the log file.

The URL will look like the following image:

Then, load the URL:

The Laravel.log file was created, and we will open the following log file:

Here, you can check all your application errors.

Conclusion

In this article, we discussed how Laravel logging was accomplished in three processes. The processes included installing Laravel 9 in the system, configuring log in the project, and running and testing the system. We hope this article will help you with your application activity.



Source link


Laravel 9 has an excellent feature named Eloquent. It is an ORM (object-relational mapping), and it helps users to communicate between applications to databases very easily. In Laravel 9, when we use Eloquent, it works as a “Model” and communicates with the database. It helps you get data from the table in the database.

In Laravel 9, there are multiple ways to get data by order. One way is shown below:

Today, we will learn how to use orderBy in Laravel and when to use it.

orderBy in Laravel

In Laravel 9, when we need to sort our data collection by descending or ascending order from the database. Then we need to use an orderBy in the Laravel query. In the regular MySQL queries, we use it as shown below:

Select * from ‘collection’ where ‘status’ = ‘something’ order by ‘collection_id asc

But, Laravel has a different way of assigning the following:

->orderBy(‘collection_id’, ‘asc’)

Project requirements are given below:

  • MySQL 8.0+
  • MariaDB 10.2+
  • PHP 8.1

Here is an example of defining the orderBy query:

  1. Process1. Create an orderBy Project
  2. Process 2. Database Connection
  3. Process 3. Apply the orderBy Method
  4. Process 4. Run and Test the orderBy Project

Process 1. Create an OrderBy Project

Now, we need to run this command to create this project:

Composer createproject Laravel/Laravel orderByProject

Process 2. Database Connection

Open the .env file on the orderByProject project and add new database details.

Here’s the following code:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Database name
DB_USERNAME=Database user name
DB_PASSWORD=Database password

Check the following image:

Process 3. Apply the orderBy Method

Before we apply orderBy to our project, we will need to create a database table for our database. For that, we will create a table called “CollectionList”. We have to run the following command to create the table:

php artisan make:modelCollectionList m

The code is provided below:

return new class extends Migration
{

    public function up()
    {
Schema::create(‘collection_lists’, function (Blueprint $table) {
            $table->id();  //coche increment
            $table->timestamps();
        });
    }

    public function down()
    {
Schema::dropIfExists(‘collection_lists’);
    }
};

I need to add these two to the following code:

$table>string(‘name’)>nullable();
$table>longText(‘details’)>nullable();

Let’s migrate the data to the database. Run the following command:

Next, create a controller to manage the function with the query.

Here, we created a controller named “CollectionList” for our OrderBy project. We need to run this command to create the following project:

php artisan make:controllerCollectionList

The code should look like this:

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;

class CollectionList extends Controller
{
    //
}

Now, I need to create a function in the controller:

The name of the function isallCollection.

After adding this function, it should look as follows:

<?php

namespace AppHttpControllers;

use AppModelsCollectionList as ModelsCollectionList;
use IlluminateHttpRequest;

class CollectionList extends Controller
{
    public function allCollection()
    {
        $alldata = ModelsCollectionList::orderBy(«id», «asc»)->get();

        return view(‘welcome’,compact(‘alldata’));
    }
}

For the get() method, we need to use data in ascending order:

   $alldata = ModelsCollectionList::orderBy(«id», «asc»)>
get();

To get the data in descending order, we need to use the following:

   $alldata = ModelsCollectionList::orderBy(«id», «desc»)>get();

Add a view under the resourceView folder called welcome.blade.php.

<html>

<head>
<meta name=«viewport» content=«width=device-width, initial-scale=1.0»>
<link href=«//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css» rel=«stylesheet» id=«bootstrap-css»>
<script src=«//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js»></script>
<script src=«//code.jquery.com/jquery-1.11.1.min.js»></script>
<!—— Include the above in your HEAD tag ———->

<head>

<div class=«container»>
<div class=«row»>
<div class=«col-md-12 text-right»>

</div>
</div>
            @foreach($alldata as $each_article)
<div class=«col-md-12»>
<h1>{{$each_article->name}}</h1>

<hr>

</div>
            @endforeach
</div>

</html>

Now, we need to add a route in routesweb.php:

Route::get(‘/collection’, [CollectionList::class, ‘allCollection’])->name(‘allCollection’);

Process 4. Run and Test the orderBy Project

Next, we need to run the following:

For the ascending order, the project will look like the following image:

For the descending order, it looks like the following image:

Conclusion

In this article, we created this Laravel Query project with Laravel 9. Creating a data table Laravel orderBy is very useful. We hope this orderBy project example will help you to understand the orderBy in Laravel 9.



Source link


Completo visionaries headline the premier open source event in Europe to share on OSS adoption in Europe, driving the circular economy, finding inspiration through the pandemic, supply chain security and more.

SAN FRANCISCO, August 4, 2022 —  The Linux Foundation, the nonprofit organization enabling mass innovation through open source, today announced the keynote speakers for Open Source Summit Europe, taking place September 13-16 in Dublin, Ireland. The event is being produced in a hybrid format, with both in-person and supuesto participation available, and is co-located with the Hyperledger Completo Forum, OpenSSF Day, Linux Kernel Maintainer Summit, KVM Forum, and Linux Security Summit, among others.

Open Source Summit Europe is the leading conference for developers, sys admins and community leaders – to gather to collaborate, share information, gain insights, solve technical problems and further innovation. It is a conference umbrella, composed of 13 events covering the most important technologies and issues in open source including LinuxCon, Embedded Linux Conference, OSPOCon, SupplyChainSecurityCon, CloudOpen, Open AI + Data Forum, and more. Over 2,000 are expected to attend.

2022 Keynote Speakers Include:

  • Hilary Carter, Vice President of Research, The Linux Foundation
  • Bryan Che, Chief Strategy Officer, Huawei; Cloud Native Computing Foundation Governing Board Member & Open 3D Foundation Governing Board Member
  • Demetris Cheatham, Senior Director, Diversity, Inclusion & Belonging Strategy, GitHub
  • Gabriele Columbro, Executive Director, Fintech Open Source Foundation (FINOS)
  • Dirk Hohndel, Chief Open Source Officer, Cardano Foundation
  • ​​Ross Mauri, Militar Manager, IBM LinuxONE
  • Dušan Milovanović, Health Intelligence Architect, World Health Organization
  • Mark Pollock, Explorer, Founder & Collaborator
  • Christopher “CRob” Robinson, Director of Security Communications, Product Assurance and Security, Intel Corporation
  • Emilio Salvador, Head of Standards, Open Source Program Office, Google
  • Robin Teigland, Professor of Strategy, Management of Digitalization, in the Entrepreneurship and Strategy Division, Chalmers University of Technology; Director, Ocean Data Factory Sweden and Founder, Peniche Ocean Watch Initiative (POW)
  • Linus Torvalds, Creator of Linux and Git
  • Jim Zemlin, Executive Director, The Linux Foundation

Additional keynote speakers will be announced soon. 

Registration (in-person) is offered at the price of US$1,000 through August 23. Registration to attend virtually is $25. Members of The Linux Foundation receive a 20 percent discount off registration and can contact events@linuxfoundation.org to request a member discount code. 

Health and Safety
In-person attendees will be required to show proof of COVID-19 vaccination or provide a negative COVID-19 test to attend, and will need to comply with all on-site health measures, in accordance with The Linux Foundation Code of Conduct. To learn more, visit the Health & Safety webpage.

Event Sponsors
Open Source Summit Europe 2022 is made possible thanks to our sponsors, including Diamond Sponsors: AWS, Google and IBM, Platinum Sponsors: Huawei, Intel and OpenEuler, and Gold Sponsors: Cloud Native Computing Foundation, Codethink, Docker, Mend, NGINX, Red Hat, and Styra. For information on becoming an event sponsor, click here or email us.

Press
Members of the press who would like to request a press pass to attend should contact Kristin O’Connell.

ABOUT THE LINUX FOUNDATION
Founded in 2000, the Linux Foundation and its projects are supported by more than 2,950 members. The Linux Foundation is the world’s leading home for collaboration on open source software, hardware, standards, and data. Linux Foundation projects are critical to the world’s infrastructure including Linux, Kubernetes, Node.js, ONAP, Hyperledger, RISC-V, and more. The Linux Foundation’s methodology focuses on leveraging best practices and addressing the needs of contributors, users, and solution providers to create sustainable models for open collaboration. For more information, please visit us at https://linuxfoundation.org/

The Linux Foundation Events are where the world’s leading technologists meet, collaborate, learn and network in order to advance innovations that support the world’s largest shared technologies.

Visit our website and follow us on Twitter, LinkedIn, and Facebook for all the latest event updates and announcements.

The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see its trademark usage page: www.linuxfoundation.org/trademark-usage. Linux is a registered trademark of Linus Torvalds. 

###

Media Contact
Kristin O’Connell
The Linux Foundation
koconnell@linuxfoundation.org





Source link


In Deep Learning, we have to fill the pixels of an image in an array or in a matrix. To accomplish this, TensorFlow.js supports the tf.fill() function. It is used to set the same value in the tensor array or tensor matrix.

tf.fill() Meethod

The tf.fill() function is used to set the element in a tensor with specified value.

We can fill that value more than one time in a tensor.

Syntax:

tf.fill(shape,value,dtype)

 
It takes three parameters.

Parameters:

    1. The shape is used to set the value n times. If it is a two-dimensional tensor, we can specify the number of rows and number of columns.
    2. The value is the numeric or string element that is filled in a tensor.
    3. The dtype is used to specify the element type.

Example 1

Create a 1D tensor with numeric value -2 ,10 times in a tensor.

<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h1>Linux Hint</h1></center>
<center><h2>Tensorflow.js – tf.fill() </h2></center>
<script>
 //create a tensor with value-2 and fill 10 times.
let values = tf.fill(shape = [10],value = 2)
//contemporáneo tensor
document.write(«Tensor: «,values);
 
</script>
 
</body>
</html>

 
Output:


2 is added 10 times to a tensor.

Example 2

Create a 1D tensor with string value, ‘Linux Hint’, 4 times in a tensor.

<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h1>Linux Hint</h1></center>
<center><h2>Tensorflow.js – tf.fill() </h2></center>
<script>
 //create a tensor with element-‘Linux Hint’ and fill 4 times.
let values = tf.fill(shape = [4],value=‘Linux Hint’,dtype=‘string’)
//contemporáneo tensor
document.write(«Tensor: «+values);
 
</script>
 
</body>
</html>

 
Output:


‘Linux Hint’ is added 4 times to a tensor with string data type.

Example 3

Create a 2D tensor with numeric value – 20, 6 (2 rows and 3 columns) times using tf.fill().

<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h1>Linux Hint</h1></center>
<center><h2>Tensorflow.js – tf.fill() </h2></center>
<script>
 //create a tensor with element-‘Linux Hint’ and fill 5 times.
let values = tf.fill(shape = [2,3],value=20)
//contemporáneo tensor
document.write(«Tensor: «+values);
 
</script>
 
</body>
</html>

 
Output:


The value, 20, is added in tensor with shape 2 rows and 3 columns.

Conclusion

We saw how to fill values in a tensor using the fill() method. Using this method, we can specify the datatype of the element and we can create a tensor with multiple dimensions. This article discussed three different examples with string and integer data types.



Source link


NIS, an abbreviation for Network Information Service, is a distributed database that helps you to maintain configuration files consistently in your networks. It provides a mainframe-client indexing service that store and circulates the server configuration information. Notably, it helps to manage the host and client names between machines in a PC network environment.

With the previous introductory information, it is right to conclude that NIS provides management and lookup services for the users within a network. But this is only possible merienda you add the user credentials to your database.

This article will provide a step-by-step guide on adding the users to your NIS system. Besides, it will also discuss how you can check the users within your system or find a specific user within the network.

Adding NIS Users to an NIS Domain

You can follow these steps to add a new user to your Linux NIS domain:

Step 1: Log in on the Master Server

You can only add the users if you have all the privileges of an administrator. Thus, begin by becoming an administrator on the master server. Notably, you can do this by creating your NIS profile during the NIS configuration.

Step 2: Create a New User

Proceed to create a new user using the useradd command. The utility creates the entries with relevant user credentials in the /etc/passwd file and the /etc/shadow profile. The following command illustrates this step and you can replace the userID with the login ID of the user you intend to add:


Step 3: Create a Password for the New User

Use the yppasswd command to create a password for the new user. The user will use this password whenever they want to log in. In the following illustration, the UserID specifies the user whose password you are creating. This step is important to ensure that the password created is lockable and useable during logins. The password created with the initial useradd command is not lockable.


Step 4: Copy the Entry into the Master Server

The next step is to copy the new user credentials into your master server’s passwd map files. Your master server’s source files should not be in a /etc file. Proceed to copy the newly created files from both the /etc/passwd and /etc/shadow files onto the passwd input file on your server.

For instance, if you add a new user named Ken, you copy the following line from the /etc/passwd to the passwd input map file:


Similarly, the following line is what you would copy from /etc/shadow to your passwd input map files:


Step 5: Delete Entries from /etc/shadow and /etc/passwd Input Files

It is trascendental to ensure that the Makefile correctly indicates the location of the copied password input file.

Merienda you copy the entries to a map source file stored in a different directory and ascertain their location, you should proceed and delete the entries in both /etc/shadow and /etc/passwd. This action is entirely for security purposes. Delete the entries using the userdel utility on your master server as indicated in the following:


Step 6: Update Your NIS Passwd Maps

Merienda your input files in the master server are updated, you can update the passwd maps using the following command:


The previous steps help add a new user to your NIS system. Merienda through, inform the new user of the initial password assigned to them. They can then login and change the password appropriately.

Finding Users in Your NIS Domain

You can also look up the users in your NIS domain. These two methods come in handy from time to time.

a. Obtaining a List of All Users in the Domain

The ypcat passwd command displays a complete list of the users in your system. You can use it as in the following illustration:

b. Finding a Specific User

You can identify a specific user from your system by running the following command:


For example, you can look up the user named Ken in the NIS system by replacing the “username” in the command with Ken.

If the user named Ken is available, you will receive the following result:


But you can expect the following result in case the user does not exist:

Conclusion

The previous illustrations show how you can add the users to your NIS system. It also shows how you can search and find the users from your systems.

Sources:



Source link


“tf.pow() in tensorflow.js is used to raise power with respect to the values in another tensor.”

Scenario 1: Work With Scalar

Scalar will store only one value. But anyway, it returns a tensor.

Syntax

Parameters
scalar1 and scalar2 are the tensors that can take only one value as a parameter.

Return
Return remainder of two scalar values.

Example
Create two scalars and raise the power to value present in the second scalar.

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//scalar1
let  value1 = tf.scalar(3);

//scalar2
let  value2 = tf.scalar(4);

document.write(«Scalar-1: «,value1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Scalar-2: «,value2);
</script>
<h3>Tensorflow.js tf.pow() </h3>

<script>
//tf.pow(value1,value2)
document.write(tf.pow(value1,value2));
</script>

</body>
</html>

Output

Working
3 to the power of 4 => 3*3*3*3 = 81.

Scenario 2: Work With Tensor

A tensor can store multiple values; it can be single or multi-dimensional.

Syntax

Parameters
tensor1 and tensor2 are the tensors that can take only single or multiple values as a parameter.

Return
Power of values.

We must notice that the total number of elements in both the tensors must be equal.

Example 1
Create two one-dimensional tensors and return the power of elements in a first tensor concerning values in a second tensor.

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor1
let  values1 = tf.tensor1d([2,3,4]);

//tensor2
let  values2 = tf.tensor1d([1,2,3]);

document.write(«Tensor-1: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Tensor-2: «,values2);
</script>
<h3>Tensorflow.js tf.pow() </h3>

<script>
//tf.pow(values1,values2)
document.write(tf.pow(values1,values2));
</script>

</body>
</html>

Output

Working
[2 power 1,3 power 2,4 power 3,] => Tensor [2,9,64].

Example 2
Create 2 two-dimensional tensors with 2 rows and 3 columns and apply tf.pow().

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor1
let  values1 = tf.tensor2d([1,2,3,4,5,6],[2,3]);

//tensor2
let  values2 = tf.tensor2d([2,2,2,2,2,2],[2,3]);

document.write(«Tensor-1: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Tensor-2: «,values2);
</script>
<h3>Tensorflow.js tf.pow() </h3>

<script>
//tf.pow(values1,values2)
document.write(tf.pow(values1,values2));
</script>

</body>
</html>

Output

Scenario 3: Work With Tensor & Scalar

It can be possible to raise the power of each element in a tensor by a scalar.

Syntax

Example
Create a one-dimensional tensor,  a scalar, and raise each element in a tensor to a scalar value.

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor
let  values1 = tf.tensor1d([10,20,30,4,5,6]);

//scalar
let  value2 = tf.scalar(2);

document.write(«Tensor: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Scalar: «,value2);
</script>
<h3>Tensorflow.js tf.pow() </h3>

<script>
//tf.pow(values1,value2)
document.write(tf.pow(values1,value2));
</script>

</body>
</html>

Output

Conclusion

tf.pow() in tensorflow.js is used to raise power with respect to the values in another tensor. Also, we noticed that scalar will store only one value and returns a tensor. While performing tf.pow() on two tensors, ensure that the number of elements in two tensors must be the same.



Source link


We already know how to create a tensor in the tensorflow.js library and display all the values from it. Now, the task is to return only some portion/range of elements from a tensor.

How do you do that?

The answer is quiebro simple. Tensorflow.js library supports the tf.slice() function which returns the elements based on the index. The index starts with 0.

Let’s see how to get the elements from a tensor.

Tensorflow.js – tf.slice()

The tf.slice() function is used to return elements from a tensor within the range and return those range of elements in a new tensor. It takes three parameters.

Syntax:

tf.slice(tensor.start,size)

 
Parameters:

    1. Tensor can be single or two-dimensional.
    2. Start specifies the index position in which the starting range is specified.
    3. Size takes an integer that returns the elements from the starting range.

Example 1:

Create a one-dimensional tensor with 10 integer values and get the following range of values:

    1. From index-0 to index-6 (start should be 0 and size is 7)
    2. From index-0 to index-8 (start should be 0 and size is 9)
    3. From index-3 to index-8 (start should be 3 and size is 6)
    4. From index-4 to index-9 (start should be 4 and size is 6)
<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h2>Tensorflow.js – tf.slice() </h2></center>
<script>
 
 //create a tensor
let values = tf.tensor1d([1,2,3,4,5,6,7,8,9,10]);
//presente tensor
document.write(«<b>Coetáneo Scalar: </b>»,values);
 
document.write(«<br>»);
 
// index-0 to index-6
document.write(«<b>Elements from index-0 to index-6: </b> «+tf.slice(values,[0],7));
document.write(«<br>»);

// index-0 to index-8
document.write(«<b>Elements from index-0 to index-8: </b> «+tf.slice(values,[0],9));
document.write(«<br>»);

// index-3 to index-8
document.write(«<b>Elements from index-3 to index-8: </b> «+tf.slice(values,[3],6));
document.write(«<br>»);

// index-4 to index-9
document.write(«<b>Elements from index-4 to index-9: </b> «+tf.slice(values,[4],6));
document.write(«<br>»);
</script>
 
</body>
</html>

 
Output:


We got the elements from index-0 to index-6. The total number of elements is 7.

Hence, we specified the size as 7.

Similarly:

    1. From index-0 to index-8, the size is 9.
    2. From index-3 to index-8, the size is 6.
    3. From index-4 to index-9, the size is 6.

Example 2:

Create a one-dimensional tensor with 5 integer values and get the following range of values:

    1. From index-0 to index-3 (start should be 0 and size is 4)
    2. From index-3 to index-4 (start should be 3 and size is 1)
<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h2>Tensorflow.js – tf.slice() </h2></center>
<script>
 
 //create a tensor
let values = tf.tensor1d([1,2,3,4,5]);
//presente tensor
document.write(«<b>Coetáneo Scalar: </b>»,values);
 
document.write(«<br>»);
 
// index-0 to index-3
document.write(«<b>Elements from index-0 to index-3: </b> «+tf.slice(values,[0],4));
document.write(«<br>»);

// index-3 to index-4
document.write(«<b>Elements from index-3 to index-4: </b> «+tf.slice(values,[3],1));

</script>
 
</body>
</html>

 
Output:

Example 3:

Create a two-dimensional tensor with 5 rows and 4 columns (20 elements) and get the range of values from the row-index2 to row-index3.

<html>
<!—   CDN Link that delivers the Tensorflow.js framework —>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>
 
<body>
<center><h2>Tensorflow.js – tf.slice() </h2></center>
<script>
 
 //create a tensor
let values = tf.tensor2d([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],[5,4]);
//presente tensor
document.write(«<b>Coetáneo Scalar: </b>»,values);
 
document.write(«<br>»);
 
// row index-2 to row index-3
document.write(«<b>Elements from row index-2 to row index-3: </b> «+tf.slice(values,[2],2));
document.write(«<br>»);

</script>
 
</body>
</html>

 
Output:


Row index-2 => [9, 10, 11, 12] and Row index-3 => [13, 14, 15, 16].

Conclusion

At the end of this article, we learned that using the tf.slice()can be possible to get a range of elements from a tensor. We specified the three different examples to understand this concept better.

In the Deep Learning using the Tensorflow.js library, we will use this technique to get the image pixels from a particular position.



Source link


“tf.div() in tensorflow.js is used to perform element wise division on two tensors/scalars.”

Scenario 1: Work With Scalar

Scalar will store only one value. But anyway, it returns a tensor.

Syntax

Parameters
scalar1 and scalar2 are the tensors that can take only one value as a parameter.

Return
Return quotient of two scalar values.

Example
Create two scalars and perform a division of two scalars.

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//scalar1
let  value1 = tf.scalar(30);

//scalar2
let  value2 = tf.scalar(70);

document.write(«Scalar-1: «,value1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Scalar-2: «,value2);
</script>
<h3>Tensorflow.js tf.div() </h3>

<script>
//tf.div(value1,value2)
document.write(tf.div(value1,value2));
</script>

</body>
</html>

Output

Working
30/70 = 0.4285714030265808.

Scenario 2: Work With Tensor

A tensor can store multiple values; it can be single or multi-dimensional.

Syntax

Parameters
tensor1 and tensor2 are the tensors that can take only single or multiple values as a parameter.

Return
Return quotient of two tensors concerning each element.

We must notice that the total number of elements in both the tensors must be equal.

Example 1
Create two one-dimensional tensors and return the quotient using tf.div().

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor1
let  values1 = tf.tensor1d([10,20,30,40,50]);

//tensor2
let  values2 = tf.tensor1d([1,2,3,4,5]);

document.write(«Tensor-1: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Tensor-2: «,values2);
</script>
<h3>Tensorflow.js tf.div() </h3>

<script>
//tf.div(values1,values2)
document.write(tf.div(values1,values2));
</script>

</body>
</html>

Output

Working
[10/1,20/2,30/3,40/4,50/5] => Tensor [10, 10, 10, 10, 10].

Example 2
Create 2 two-dimensional tensors with 2 rows and 3 columns and apply tf.div().

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor1
let  values1 = tf.tensor2d([1,2,3,4,5,6],[2,3]);

//tensor2
let  values2 = tf.tensor2d([34,10,20,30,40,50],[2,3]);

document.write(«Tensor-1: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Tensor-2: «,values2);
</script>
<h3>Tensorflow.js tf.div() </h3>

<script>
//tf.div(values1,values2)
document.write(tf.div(values1,values2));
</script>

</body>
</html>

Output

Working
[[1/34,2/10,3/20],[4/30,5/40,6/50]] => [[0.0294118, 0.2 , 0.15], [0.1333333, 0.125, 0.12]].

Scenario 3: Work With Tensor & Scalar

It can be possible to divide each element in a tensor by a scalar.

Syntax

Example
Create a one-dimensional tensor and a scalar and perform division using tf.div().

<html>
<!–   CDN Link that delivers the Tensorflow.js framework –>
<script src=«https://cdn.jsdelivr.net/npm/@tensorflow/tfjs»></script>

<body>
<script>
//tensor
let  values1 = tf.tensor1d([10,20,30,4,5,6]);

//scalar
let  value2 = tf.scalar(10);

document.write(«Tensor: «,values1);

document.write(«<br>»);
document.write(«<br>»);

document.write(«Scalar: «,value2);
</script>
<h3>Tensorflow.js tf.div() </h3>

<script>
//tf.div(values1,value2)
document.write(tf.div(values1,value2));
</script>

</body>
</html>

Output

Working
[10/10, 20/10, 30/10, 4/10, 5/10, 6/10] =>  [1, 2, 3, 0.4, 0.5, 0.6].

Conclusion

tf.div() in tensorflow.js is used to perform division and return element-wise quotients. We discussed three scenarios to divide a tensor by a scalar.

Also, we noticed that scalar will store only one value and returns a tensor. While performing tf.div() on two tensors, ensure that the number of elements in two tensors must be the same.



Source link