Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Saturday, March 9, 2024

Linux command-line utilities for Ubuntu, Debian, CentOS, Fedora by G Krishna

 Dear Students,

Are you new to Linux or looking to refresh your knowledge of basic command-line utilities?

Sometimes it’s hard to keep track of all the Linux commands you use, so I created a list of some of the most useful and important ones that will make using Linux on various distributions, including Raspberry Pi (Raspbian), Ubuntu, Debian, CentOS, and Fedora, a lot easier. But first a quick note about user privileges…

There are two user “modes” you can work with in Linux. One is a user mode with basic access privileges, and the other is a mode with administrator access privileges (also known as superuser or root). Some tasks can’t be performed with basic privileges, so you’ll need to enter them with superuser privileges to perform them. You’ll frequently see the prefix sudo before commands, which means you’re telling the computer to run the command with superuser privileges.




An alternative to entering sudo before each command is to access the root command prompt, which runs every command with superuser privileges. You can access root mode by entering sudo su at the command prompt. After entering sudo su, you’ll see the root@hostname:/current/directory# command prompt, and all subsequent commands will have superuser privileges.


General Commands:

 

 aptget update: Updates the list of available packages and their versions from the repositories.

 aptget upgrade: Upgrades all installed packages to their latest versions.

 clear: Clears the terminal screen.

 date: Displays the current date.

 find / name example.txt: Searches for the file named example.txt in the entire file system and shows the directories where it's located.

 nano example.txt: Opens the Nano text editor with the file example.txt.

 poweroff: Shuts down the system immediately.

 raspiconfig: Opens the Raspberry Pi configuration settings menu.

 reboot: Restarts the system immediately.

 shutdown h now: Shuts down the system immediately.

 shutdown h 01:22: Schedules a shutdown for 1:22 AM.

 startx: Initiates the Graphical User Interface (GUI).

 

File and Directory Commands:

 

 cat example.txt: Displays the contents of example.txt.

 cd /abc/xyz: Changes the current directory to /abc/xyz.

 cp XXX: Copies the file or directory XXX to a specified location.

 ls l: Lists files in the current directory with details such as size, date modified, and permissions.

 mkdir example_directory: Creates a new directory named example_directory.

 mv XXX: Moves the file or directory XXX to a specified location.

 rm example.txt: Deletes the file example.txt.

 rmdir example_directory: Deletes the directory example_directory if it's empty.

 scp user@10.0.0.32:/some/path/file.txt: Copies a file over SSH from a remote PC to the Raspberry Pi.

 touch example.txt: Creates a new empty file named example.txt.

 

Networking and Internet Commands:

 

 ifconfig: Checks the status of the wireless connection, particularly wlan0's IP address.

 iwconfig: Displays information about the wireless adapter's network.

 iwlist wlan0 scan: Lists currently available wireless networks.

 iwlist wlan0 scan | grep ESSID: Lists only the ESSIDs (network names).

 nmap: Scans the network and lists connected devices and other details.

 ping: Tests connectivity between devices on the network.

 wget http://www.website.com/example.txt: Downloads example.txt from a website to the current directory.

 

System Information Commands:

 

 cat /proc/meminfo: Shows details about memory.

 cat /proc/partitions: Displays partition size and number.

 cat /proc/version: Shows the Raspberry Pi version.

 df h: Shows disk space information.

 df /: Shows free disk space.

 dpkg getselections | grep XXX: Lists installed packages related to XXX.

 dpkg getselections: Lists all installed packages.

 free: Shows free memory.

 hostname I: Displays the Raspberry Pi's IP address.

 lsusb: Lists connected USB hardware.

 UP key: Repeats the last command entered.

 vcgencmd measure_temp: Shows CPU temperature.

 vcgencmd get_mem arm && vcgencmd get_mem gpu: Displays memory split between CPU and GPU.


No comments:

Post a Comment