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

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

Monday, June 19, 2017

Get only matching words using Grep in a command Linux, Shell command

We can use Grep to get the fields or string which contains the specified character, word or string.

cat filename|grep -oh "\w*@\w*"

so suppose a test file contains:

2017-06-19 01:04:49 trigproc man-db:amd64 2.7.5-1 <none>
2017-06-19 01:04:49 status half-configured man-db:amd64 2.7.5-1
2017-06-19 01:04:50 status installed man-db:amd64 2.7.5-1
2017-06-19 01:04:50 configure vim-runtime:all 2:8.0.0095-1ubuntu3 <none>
2017-06-19 01:04:50 status unpacked vim-runtime:all 2:8.0.0095-1ubuntu3
2017-06-19 01:04:50 status half-configured vim-runtime:all 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status installed vim-runtime:all 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 trigproc gnome-menus:amd64 3.13.3-6ubuntu4 <none>
2017-06-19 01:04:51 status half-configured gnome-menus:amd64 3.13.3-6ubuntu4
2017-06-19 01:04:51 status installed gnome-menus:amd64 3.13.3-6ubuntu4
2017-06-19 01:04:51 trigproc hicolor-icon-theme:all 0.15-1 <none>
2017-06-19 01:04:51 status half-configured hicolor-icon-theme:all 0.15-1
2017-06-19 01:04:51 status installed vim-common:all 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status installed hicolor-icon-theme:all 0.15-1
2017-06-19 01:04:51 configure vim-tiny:amd64 2:8.0.0095-1ubuntu3 <none>
2017-06-19 01:04:51 status unpacked vim-tiny:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status unpacked vim-tiny:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status half-configured vim-tiny:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status installed vim-tiny:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 configure vim:amd64 2:8.0.0095-1ubuntu3 <none>
2017-06-19 01:04:51 status unpacked vim:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status half-configured vim:amd64 2:8.0.0095-1ubuntu3
2017-06-19 01:04:51 status installed vim:amd64 2:8.0.0095-1ubuntu3


in a file /tmp/test then if we want to get all word with ubun we can give the command as

grep -oh "\w*ubun\w*" /tmp/test

will give this word from all lines.

Tuesday, January 29, 2013

View file sise sorted, file size/folder size sorted in size

du -sm * | sort -nr --> Decending

du -sm * | sort -n  --> Ascending

du -sc * | sort -nr --> Total size of current folder

du -sm * | sort -nr | head -10 --> First 10 : Top 10 Largest Items

du -sm * | sort -nr | tail -10
--> Last 10

ls -ltr | grep [0-9][0-9][0-9]M/G  -->  will show files withree digit number in MB or GB

Sunday, April 15, 2012

Scp command in linux (Secure copy)

Do you need to copy some files from on Linux machine to other or from one Linux use to other user??? so here is the Linux command which you can use to copy files from one Linux machine to other only if you know the password :) for sure, as using this command you can copy file without need of any messenger of such kind of utility so i am giving this any way you can always install "iptux" using which you can transfer files inside LAN.
Any how lets talk about the command which I was talking the command is called SCP which means secure copy.

Here is the explanation about the command :

Find command in Ubuntu

Find (find) searches any set of directories you specify for files that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria. The search is recursive in that it will search all subdirectories.

 Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

uname command in ubuntu

Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order,
                             except omit -p and -i if unknown:
  -s, --kernel-name        print the kernel name
  -n, --nodename           print the network node hostname
  -r, --kernel-release     print the kernel release
  -v, --kernel-version     print the kernel version
  -m, --machine            print the machine hardware name
  -p, --processor          print the processor type or "unknown"
  -i, --hardware-platform  print the hardware platform or "unknown"
  -o, --operating-system   print the operating system
      --help     display this help and exit
      --version  output version information and exit

Featured Posts

Run Commands for Windows

  🖥️ CPL Files (Control Panel Applets) Run via Win + R → filename.cpl Command Opens appwiz.cpl P...