WebHosting

Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Sunday, October 15, 2023

Some Useful and less know #Linux commands



1. cal: Display a #calendar for the current or specified month.

   -----------------------------------------------------------

   cal

   -----------------------------------------------------------

   

2. units: Convert units from one measurement to another.

   -----------------------------------------------------------

   units "feet to meters"

   -----------------------------------------------------------

   

3. figlet: Create text banners using ASCII art fonts.

   -----------------------------------------------------------

   figlet Hello, Linux!

   -----------------------------------------------------------

   

4. toilet: Generate text-based art and banners.

   -----------------------------------------------------------

   toilet -f term Hello, Linux!

   -----------------------------------------------------------

   

5. cowsay: Display text in speech bubbles from an ASCII art cow.

   -----------------------------------------------------------

   cowsay "Moo, I'm a cow!"

   -----------------------------------------------------------

   

6. sl: Display a steam locomotive in the terminal when you mistype `ls`.

   -----------------------------------------------------------

   sl

   -----------------------------------------------------------

   

7. rev: Reverse the order of characters in a file or string.

   -----------------------------------------------------------

   echo "Linux" | rev

   -----------------------------------------------------------

   

8. fortune: Get a random, often humorous, text message.

   -----------------------------------------------------------

   fortune

   -----------------------------------------------------------

   

9. yes: Output a continuous stream of "yes" until manually stopped.

   -----------------------------------------------------------

   yes

   -----------------------------------------------------------

   

10. watch: Execute a command repeatedly and display the output in real-time.

    -----------------------------------------------------------

    watch -n 1 "date"

    -----------------------------------------------------------

11. cmatrix: Display the falling characters similar to "The Matrix."

    -----------------------------------------------------------

    cmatrix

    -----------------------------------------------------------

12. slurm: Network bandwidth usage monitoring.

    -----------------------------------------------------------

    slurm -i eth0

    -----------------------------------------------------------

13. qrencode: Generate QR codes from text.

    -----------------------------------------------------------

    qrencode -o qr.png "https://www.example.com"

    -----------------------------------------------------------

14. lshw: List hardware information.

    -----------------------------------------------------------

    lshw

    -----------------------------------------------------------

15. tree: Display directory structure in a tree-like format.

    -----------------------------------------------------------

    tree /path/to/directory

    -----------------------------------------------------------

16. apropos: Search man page names and descriptions for keywords.

    -----------------------------------------------------------

    apropos keyword

    -----------------------------------------------------------

17. ranger: A console-based file manager with VI keybindings.

    -----------------------------------------------------------

    ranger

    -----------------------------------------------------------

18. htop: An interactive process viewer and system monitor.

    -----------------------------------------------------------

    htop

    -----------------------------------------------------------

19. ncdu: A disk usage analyzer with an ncurses interface.

    -----------------------------------------------------------

    ncdu

    -----------------------------------------------------------

20. tldr: A simplified and community-driven man pages.

    -----------------------------------------------------------

    tldr command

    -----------------------------------------------------------

These less-known Linux commands and utilities can be fun to explore and might help you perform various tasks more efficiently or just bring a smile to your face with some terminal-based humor.


#LinuxCommands,#HiddenCommands,#TerminalTricks,#LinuxUtilities,#UsefulCommands,#CommandLineFun,#LinuxTips,#ASCIIArt,#TextBanners,#LinuxTools

Saturday, September 30, 2023

Troubleshooting process-related issues in Linux often involves various commands and checks. Here are some important Linux commands for process troubleshooting

1. **List Running Processes:** Use `ps aux` or `top` to list currently running processes.

2. **Check Process Details:** Use `ps -p <PID>` to view detailed information about a specific process.

3. **Kill a Process:** Use `kill` or `killall` to terminate processes, e.g., `kill <PID>`.

4. **Find Process by Name:** Use `pgrep` to find processes by name, e.g., `pgrep <process_name>`.

5. **View Process Tree:** Use `pstree` to display the process tree.

6. **Check Process Limits:** Use `ulimit -a` to view process-level resource limits.

7. **Check Process CPU Usage:** Use `htop` or `top` to monitor CPU usage by processes.

8. **Check Process Memory Usage:** Use `htop` or `top` to monitor memory usage by processes.

9. **Check Process Disk I/O:** Use `iotop` to monitor disk I/O by processes.

10. **Check Process Network Activity:** Use `iftop` or `nethogs` to monitor network activity by processes.

11. **Check Process Priority:** Use `nice` and `renice` to set or adjust process priority.

12. **Check Open Files by Process:** Use `lsof` to list open files and sockets by process.

13. **Check Process Environment:** Use `cat /proc/<PID>/environ` to view the environment variables of a process.

14. **Check Process Threads:** Use `ps -p <PID> -L` to list threads of a process.

15. **Check Process Dependencies:** Use `ldd` to list shared library dependencies of a binary.

16. **Monitor Process Resource Usage:** Use `sar` or `pidstat` to monitor various resource usage by processes.

17. **Check Process Start Time:** Use `ps -p <PID> -o lstart` to check the start time of a process.

18. **Check Zombie Processes:** Use `ps aux | grep 'Z'` to identify and handle zombie processes.

19. **Check Process Traces:** Use `strace` or `ltrace` to trace system or library calls made by a process.

20. **Process Management with systemd:** Use `systemctl` to start, stop, enable, or disable services and processes managed by systemd.

#ProcessIssues, #ProcessTroubleshooting, #ProcessManagement, #ProcessMonitoring, #ResourceUsage, #ProcessTree, #KillProcess, #CPUUsage, #MemoryUsage, #DiskIO, #NetworkActivity, #ProcessPriority, #OpenFiles, #EnvironmentVariables, #ProcessThreads, #DependencyAnalysis, #ResourceMonitoring, #ZombieProcesses, #ProcessTracing, #SystemdServices

Tuesday, September 26, 2023

Some tips and tricks for using the `#sudo` #command

1. Limit Access: By default, `sudo` allows authorized users to execute any command with elevated privileges. You can restrict access to specific commands or command categories by editing the `/etc/sudoers` file using the `visudo` command. For example, to allow a user to only run the `reboot` command:

 

   username ALL=/sbin/reboot

 

2. Customize the Prompt: You can customize the `sudo` command prompt to display a warning message or provide context for the command being executed. Edit the `sudoers` file and add a `Defaults` line with the `lecture` option:

 

   Defaults        lecture=always

   Defaults        lecture_file=/etc/sudo_lecture

 

3. Timestamp and Timeout: By default, `sudo` caches your credentials for a certain period (usually 5 minutes) to avoid repetitive password prompts. You can adjust the timeout duration by editing the `sudoers` file:

 

   Defaults        timestamp_timeout=10

 

4. Check User Privileges: You can verify which commands a user can run with `sudo` privileges by running:

 

   sudo -l

 

5. Running GUI Applications: If you need to run graphical applications with `sudo`, use `sudo -H` or `sudo -i` to set the `HOME` environment variable correctly:

 

   sudo -H gedit

 

6. Avoid `sudo su`: Instead of running `sudo su` to become the root user interactively, use `sudo -i` or `sudo -s` for a shell session with elevated privileges. This avoids potential issues with environment variables.

 

   sudo -i

 

7. Audit `sudo` Usage: You can enable auditing of `sudo` commands to keep track of who is using `sudo` and what commands are executed. Refer to your system's auditd or auditctl configuration for this.

8. Use `sudo !!`: If you forget to prefix a command with `sudo`, you can run it with elevated privileges using `sudo !!`. For example:

 

   apt update

   sudo !!  # Executes 'sudo apt update'

 

9. Secure Password Entry: To ensure your password is hidden while entering it for `sudo`, use the `-S` option:

 

   sudo -S command

 

10. Temporary Elevation: If you need to run multiple commands as the superuser in the same terminal session, you can use `sudo -s` to start an elevated shell:

  

    sudo -s

  

11. Insider Information: To display information about the user's `sudo` privileges, run:

  

    sudo -l

  

12. Enable Root Account: You can enable and set a password for the root account, but this is generally discouraged in favor of using `sudo`.

Remember that with great power comes great responsibility. Always use `sudo` cautiously to avoid unintentional system changes or security risks.

Sunday, August 14, 2022

#Linux #Commands by #Category : #AllLinuxCommand #linux...Linux

#FileOperation
#ls : List files in a directory.
#cp: Copy a file.
#mv: Rename (“move”) a file.
#rm: Delete (“remove”) a file.
#ln: Create links (alternative names) to a file.
#shred: Completely erase a file when the file is deleted

#DirectoryOperation
#cd: Change your current directory.
#pwd: Print the name of your current directory.
#basename: Print the final part of a file path.
#dirname: Print a file path without its final part.
#mkdir: Create (make) a directory.
#rmdir: Delete (remove) an empty directory.
#rm -r: Delete a nonempty directory and its contents.

#ViewingFiles
#cat: View files in their entirety. cat [filename]
#less: View text files one page at a time. less [filename]
#head: View the first lines of a text file. head [filename]
#tail:  View the last lines of a text file. tail [filename]
#nl: View text files with their lines numbered. nl [filename]
#strings: Display text that’s embedded in a binary file. strings [filename]
#od: View data in octal (or other formats). oc [filename]
#xxd: View data in hexadecimal.xxx [filename]
#gv: View PostScript or PDF files. sudo apt install gv [filename]
#xdvi: View TeX DVI files. sudo apt install xdiv xdiv [filename]

#JobControl #commands
#jobs: List your jobs.
#&: Run a job in the background.
#^Z: Suspend the current (foreground) job.
#suspend: Suspend a shell.
#fg: Un-suspend a job: bring it into the foreground.
#bg: Make a suspended job run in the background.
#kill -STOP/-CONT : pausing continuing process

#FileCreation and #Editing
#Vim: Open file/ Create a File
#Vi : Open File/ Create a File.
#Nano : Open File/ Create a File
#Emacs : Open/Create File
#Edit: Graphical File Editor
#Ed: is a line-oriented text editor. It is used to create, display, modify and text files

#File Property Commands
#stat: Display attributes of files and directories.
#wc: Count bytes, words, lines in a file.
#du: Measure disk usage of files and directories.
#file: Identify (guess) the type of a file.
#touch: Change timestamps of files and directories.
#chown: Change owner of files and directories.
#chgrp: Change group ownership of files and directories.
#chmod: Change protection mode of files and directories.
#umask: Set a default mode for new files and directories.
#chattr: Change extended attributes of files and directories.
#lsattr: List extended attributes of files and directories.

#SearchingFiles #Location
#find: Locate files in a directory hierarchy.
#xargs: Process a list of located files (and much more).
#locate: Create an index of files, and search the index for string.
#which: Locate executables in your search path (command).
#type: Locate executables in your search path (bash built-in).
#whereis: Locate executables, documentation, and source files.

#File content manipulation 
#grep: Find lines in a file that match a regular expression.
#cut: Extract columns from a file.
#paste: Append columns.
#tr: Translate characters into other characters.
#sort: Sort lines of text by various criteria.
#uniq: Locate identical lines in a file.
#tee: Copy a file and print it on standard output, simultaneously.

#File #Compression and #Packaging
#tar: Package multiple files into a single file.
#gzip: Compress files with GNU Zip.
#gunzip: Uncompress GNU Zip files.
#bzip2: Compress files in BZip format.
#bunzip2: Uncompress BZip files.
#bzcat: Compress/uncompress BZip files via standard input/output.
#compress: Compress files with traditional Unix compression.
#uncompress: Uncompress files with traditional Unix compression.
#zcat: Compress/uncompress file via standard input/output (gzip or compress).
#zip: Compress files in Windows Zip format.
#unzip: Uncompress Windows Zip files.
#metamail: Extract MIME data to files.

#Filescomparision
#diff: Line-by-line comparison of two files or directories.
#comm: Line-by-line comparison of two sorted files.
#cmp: Byte-by-byte comparison of two files.
#md5sum: Compute a checksum of the given files (MD5).

#Printer/#Printing 
#lpr: Print a file.
#lpq: View the print queue.
#lprm: Remove a print job from the queue.

#Spelling Checking
#look: Look up the spelling of a word quickly.
#aspell: Interactive spelling checker.
#spell: Batch spelling checker.

#Disk and #FileSystem
#df: Show information about the file system on which each FILE resides, or all file systems by default.
#du : Summarize disk usage of the set of FILEs, recursively for directories.
#mount: Make a disk partition accessible.
#umount: Unmount a disk partition (make it inaccessible).
#fsck: Check a disk partition for errors.
#sync: Flush all disk caches to disk.
#lshw :List all hardware
#lsblk :List information about block devices. 
#findmnt: Find a (mounted) filesystem.
#blkid : locate/print block device attributes
#fdisk : Display or manipulate a disk partition table.
#mkfs: Make file filesystem
#mkswap: Make a swap area on a device or in a file
#parted: Disk partitioning and partition resizing program.  It allows the user to create, destroy, resize, move and copy ext2, ext3, Linux-swap,  FAT  and FAT32 partitions.
#sfdisk: List the size of a partition, the partitions on a device, check the partitions on a device, and repartition a device.
#file: Determine type of FILEs

#Backup and #Remote #Storage
#dump: Write a disk partition to a backup medium.
#restore: used for restoring files from a backup created using dump.
#cdrecord: record audio or data CD, DVD or BluRay
#rsync: is a file transfer program capable of efficient remote update via a fast differencing algorithm.
#mt: Control magnetic tape drive operation.
#cpio: copies files to and from archives
#cp/scp : copy/ remote copy files
#dd: in simplest terms copies an image of a selected disk area. Then provides the ability to copy selected blocks of a physical disk.
#tar/zip/gzip : compress files

#Monitoring #Linux system
#ps: List process.
#uptime: View the system load.
#w: List active processes for all users.
#top: Monitor resource-intensive processes interactively.
#htop: utility that allows the user to interactively monitor the system's vital resources or server's processes in real time.
#iotop: display and monitor the disk IO usage details and even gets a table of existing IO utilization by the process
#gnome-system-monitor: Monitor system load and processes graphically.
#xload: Simple, graphical monitor of system load.
#free: Display free memory.
#pidof: Command, which looks up and prints the PID of a process by its name
#nmon: fully interactive performance monitoring command-line utility tool for Linux. It is a benchmark tool that displays performance about the CPU, MEMORY, NETWORK, DISKS, FILE SYSTEM, NFS, TOP PROCESSES, RESOURCES, AND POWER MICRO-PARTITION
#lsof : display a list of all the open files and the processes. The open files included are disk files, network sockets, pipes, devices, and processes.
#iostat: Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
#Psacct or Acct : monitor user activities
#whowatch – Monitor Linux Users and Processes in Real Time
#vmstat: display statistics of virtual memory, kernel threads, disks, system processes, I/O blocks, interrupts, CPU activity, and much more

#Network Related
#traceroute: View the network path to a remote host.
#ifconfig: Older command to set and display network interface information.
#netstat: list of all active connections.
#who: List logged-in users, long output.
#tcpdump: listing of all active connections.
#ping: Check if a remote host is reachable.
#ifup/ifdown/ifquery: actives/deactivates/query about state of a network interface.
#nslookup: queries Internet name servers interactively for information.
#dig: stands for Domain Information Groper. It is used for retrieving information about DNS name servers.
#mtr: combines the functionality of the traceroute and ping programs in a single network diagnostic tool.
#ip: used for displaying and manipulating routing, network devices, interfaces.
#ethtool: utility for querying and modifying network interface controller parameters and device drivers.
#route: utility for displaying or manipulating the IP routing table of a Linux system.
#nmcli: scriptable command-line tool to report network status, manage network connections, and control the NetworkManager.
#ss: utility to investigate sockets. It dumps socket statistics and displays information similar to netstat.
#nc: also referred to as the “Network Swiss Army knife”, is a powerful utility used for almost any task related to TCP, UDP, or UNIX-domain sockets. It is used to open TCP connections, listen on arbitrary TCP and UDP ports, perform port scanning plus more.
#host: command is a simple utility for carrying out DNS lookups, it translates hostnames to IP addresses and vice versa.

#Instant #Messaging
#write: Send messages to a terminal.
#mesg: Prohibit talk and write.
#tty: Print your terminal device name.
#wall:  allow us to send messages to another user in the terminal using tty2

#Web #Browsing
#lynx: open source command line browser 
#Links2: text-based browser that you can easily utilize on your terminal with a good user experience.
#elinks: eLinks is similar to Links2 — but it is no longer maintained.
#wget: non-interactive network downloader which is used to download files from the server 
#curl: (short for "Client URL") is a command line tool that enables data transfer over various network protocols
#W3M: open-source text-based web browser for the terminal.

#Email:
#mail: mail command is quite popular and is commonly used to send emails from the command line.
#mailx: Mailx is the newer version of mail command and was formerly referred to as nail in other implementations.
#mutt: Mutt is a lightweight Linux command line email client. Unlike the mail command that can do basic stuff, mutt can send file attachments.
#mpack: mpack command is used to encode the file into MIME messages and sends them to one or several recipients, or it can even be used to post to different newsgroups.
#sendmail: a most popular SMTP server used in most of Linux/Unix distribution. Sendmail allows sending email from command line.
#swaks: command is a scriptable, flexible, transaction-oriented SMTP tool. 
#ssmtp:  send emails using the SMTP server from the Linux terminal.

#Network Connection
#ssh: Securely log into a remote host, or run commands on it.
#telnet: Log into a remote host (insecure!).
#scp: Securely copy files to/from a remote host (batch).
#sftp: Securely copy files to/from a remote host (interactive).
#ftp: Copy files to/from a remote host (interactive, insecure!).

#Host Location
#host: Look up hostnames, IP addresses, and DNS info.
#whois: Look up the registrants of Internet domains.
#ping: Check if a remote host is reachable.
#traceroute: View the network path to a remote host.
#dig: dig is a tool for querying DNS nameservers 

#Host Information:
#uname: Print basic system information.
#lshw: extract detailed information on the hardware configuration of the machine
#lscpu: gathers CPU architecture information from sysfs, /proc/cpuinfo and any applicable architecture-specific libraries
#lsblk: lists information about all available or the specified block devices
#lsusb: displaying information about USB buses in the system and the devices connected to them
#lspci: utility for displaying information about PCI buses in the system and devices connected to them
#dmidecode: hardware information by reading data from the DMI tables
#hostname: Print the system’s hostname.
#dnsdomainname: Same as hostname -d.
#domainname: Same as hostname -y.
#nisdomainname: Same as hostname -y.
#ypdomainname: Same as hostname -y.
#ip: Set and display network interface information.
#ifconfig: Older command to set and display network interface information.
#hwinfo is used to probe for the hardware present in the system. It can be used to generate a system overview log which can be later used for support.

#User Management 
#useradd: Create an account.
#userdel: Delete an account.
#usermod: Modify an account.
#passwd: Change a password.
#chfn: Change a user’s personal information.
#chsh: Change a user’s shell.

#Group Management
#groups: Print the group membership of a user.
#groupadd: Create a group.
#groupdel: Delete a group.
#groupmod: Modify a group.

#User and Environment:
#logname: Print your login name.
#whoami:  Print your current, effective username.
#id: Print the user ID and group membership of a user.
#who: List logged-in users, long output.
#users: List logged-in users, short output.
#finger: Print information about users.
#last: Determine when someone last logged in.
#printenv: Print your environment.

#Login Logout Shutdown Reboot 
#shutdown: arranges for the system to be brought down in a safe way,All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented.
#reboot: This will reboot the system immediately
#pm-hibernate/systemctl hibernate: Most of the computer’s hardware is not capable of Hibernation. You can enter the pm-hibernate command and check.
#init 0 : Shutsdown the system
#init 6 : will reboot the system
#systemctl [halt/poweroff/reboot/suspend/hibernate] : uses systemctl command to perform action
#halt/halt -p: command allows you to halt the system, without actually powering down. if we use -p it will power off too
#poweroff: command which allows you to power off the system after shutting down.

#Scheduling jobs in Linux
#sleep: Wait a set number of seconds, doing nothing.
#watch: Run a program at set intervals.
#at: Schedule a job for a single, future time.
#crontab: Schedule jobs for many future times.

#Controlling Process:
#kill: Terminate a process (or send it a signal).
#killall: When started by a root user, the killall command cancels all cancellable processes except those processes that started it
#nice:  Invoke a program at a particular priority.
#renice: Change a process’s priority as it runs.
#cpulimit: interrupt execution of a process (or process group) if the CPU/system load goes beyond a defined threshold.
#ulimit: Used to define various limits on files/process/memory etc

Featured Posts

How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS

Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...