DEV Community

CNavya21
CNavya21

Posted on

Basic Cli commands(sudo, apt, touch, cat, less)

Sudo

  • It allow a user with proper permissions to execute a command as another user, such as the superuser.

Flags of sudo

  • -V : used to check the version.
  • -l : used to list which we have to print from current host.
  • -v : sudo will update the user’s timestamp, prompting for the user’s password if necessary.
  • -h : used to help.
  • -k : it used to sudo invalidates the user’s timestamp.
  • -K : it used to remove the user’s timestamp entirely.
  • -b : it tells sudo to run the given command in the background.
  • -p : allows you to override the default password prompt and use a custom one.
  • -u : user can run the specified command as a user other than root.
  • -s : runs the shell specified by the SHELL environment variable if it is set or the shell as specified in the file password.
  • - : indicates that sudo should stop processing command line arguments.

Syntax of sudo

sudo [command]
Enter fullscreen mode Exit fullscreen mode

apt (Advanced Packaging Tool)

  • It perform as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

  • Install package

sudo apt install <package_name>
Enter fullscreen mode Exit fullscreen mode
  • Update package in index
sudo apt update
Enter fullscreen mode Exit fullscreen mode
  • Remove a package
sudo apt remove <package_name>
Enter fullscreen mode Exit fullscreen mode
  • Upgrade package
sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

touch

  • It is used to create a file, update the modification and access time of each file with the help of touch command.

Syntax of touch

touch <file_name>
Enter fullscreen mode Exit fullscreen mode

Flags in touch

  • -a : used to change the access time of a file.
  • -m : help you to change only the modification time of a file.
  • -r : it update time with reference to the other mentioned command.
  • -t : we can change the access time of a file by determining a specified time to it.

cat

  • Create a file bye using '>' symbol.
  • It can read the data inside the file.

Syntax of cat

  • create a file
cat > 'file_name'
Enter fullscreen mode Exit fullscreen mode
  • to read a file
cat 'file_name'
Enter fullscreen mode Exit fullscreen mode

less

  • It automatically adjust with the width and height of the terminal window.
less 'file_name'
Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay