How to generate random number in Linux? You can easily generate random numbers with the custom limit range by using shuf command.
shuf is a UNIX and Linux command for generating random permutations.
Syntax for Generate random number in Linux
shuf [INPUT RANGE] [HEAD COUNT]
Example
The below example will return 7 digits random number. You can change the input range as your requirement.
- You need to pass input range as “000-999” to get 3 digit number
- You need to pass input range as “0000-9999” to get 4 digit number
- You need to pass input range as “00000-99999” to get 5 digit number
- You need to pass input range as “000000-999999” to get 6 digit number
shuf -i 0000000-9999999 -n 1
Result
73893336

Related Posts
-
cd command in Linux / Unix'cd' is a Linux command to change the current working directory or folder of the terminal (Shell). Syntax: # cd [directory / folder name] cd: cd [-L|[-P [-e]]] [dir] Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the…
-
Linux command to list out all installed fonts: fc-listfc-list lists fonts and styles available on the system using fontconfig. You can use fc-list to find out whether particular language font is installed or not. In this tutorial, I will show you how to list all installed fonts and also how to list installed fonts for a particular language…
cal - How to get monthly and yearly calendar in LinuxThe "cal" command displays a simple calendar with Linux / UNIX date and time. If no argument passed, then the current month is displayed. Month can specified as a number from 1 to 12. "cal" command without argument to get monthly calendar: Monthly calendar "cal" command with argument to get…
-
Generating Random String Using PHPGenerating random strings with custom specified length is most required functionality in every project. In this article, I described the easiest way to generate custom length random string. PHP program for Random String Generate: <?php /* * Function to generate random string * Default length 30 character */ function generateRandomString($length…
-
Find out what Perl modules already installed on Linux SystemUse 'instmodsh' command to get a complete list of installed Perl modules on your Linux system and it provides an interactive shell type interface to query details of locally installed Perl modules. Open your terminal and type the following command: instmodsh Now, you will get the list of available commands…
-
Linux cURL Commandcurl is a tool / client to transfer data from or to a server and to get documents/files from or send documents to a server, using any one of the supported protocols (HTTP, HTTPS, FTP, FTPS, GOPHER, DICT, TELNET, LDAP or FILE). The command is designed to work without user…
-
Delete / Remove User account in Linux - userdelHow do I delete / remove user account from my server? How do I delete a user account under Linux operating systems include home directory and running cron jobs? Usually the particular user (person) can be left from the company or block the access from the Linux servers based on…
-
How to get / list out installed PHP extension in Linux OSLinux widely uses operating system in the server side and client side. Operating system provides flexible options to install our custom packages and extensions based on our project requirement. Additionally, we can write our own shell scripts to automate our projects. PHP is used mainly in server-side application software along with various…
Linux finding largest files in directory recursively - find,sort,headLinux Find command is used to search and locate the list of files and directories based on conditions you specify that match the arguments. The procedure to find the largest files in a directory recursively using find command is as follows: Open the terminal applicationLogin as the root user using…
-
How to create new user account with home directory in Open SUSE LinuxTo create a new user account in Open suse, please use the below command. # useradd -g usergroup -p testpwd -d /home/testuser -m testuser Where, usergroup - With primary group /home/testuser - Home directory testuser - Login name testpwd - Password More information: useradd [options] LOGIN useradd -D useradd -D [options] Options for create…