Subset bed files

Hi everyone I am working on genotype data, I have bed, bim and fam files with the summary statistics of GWAS. Because the number of individuals are a lot, so I want to sample from my binary files in numbers of 3000 randomly . In other words, I want to subset the binary files. Do you know how can I do that by plink, R or python?